I have to add text on image like caption on images ,For that i use
ZDStickerView
I have to add fonts and different colours to caption.As i implemented fonts and colours on caption using ZDStickerView. When i zoom out that image.the colour of image get blurred.i need to create image clear without geting bur when i zoom it..
Code :
UILabel *lb1 = [[UILabel alloc ] initWithFrame:CGRectMake(0,0,320,40)];
UIimageview *imgview_sign = [[UIImageview alloc ] initWithFrame:CGRectMake(0,0,320,140)];
[imgview_sign addsubview:lbl1];
//add aZDSticker view
ZDStickerView *userResizableView = [[ZDStickerView alloc] initWithFrame:imgview_sign.frame];
userResizableView.tag = 0;
userResizableView.delegate = self;
userResizableView.contentView = imgview_sign;
userResizableView.preventsPositionOutsideSuperview = NO;
[userResizableView showEditingHandles];
[self.view addSubview:userResizableView];
//This code helps me in zooming image in and out at some fixed point using pan gesture.
Related
I am new to iPhone programming.
Using below code I can able to download and displaying all images form server. But in server I have more than some 1000s of images are there. so Using below code I can able to download and displaying in scrollview as 3*3 thumbnail.
But what I want means first I have to download and display 15 images in scrollview as 3*3 thumbnail.
If I scroll down means i have to show activity indicator then download next form 16 to 30 images, similarly again if I scroll means I want to download and display 31 to 45 images in thumbnail.
I dont want to download all images form server.
Can any tell me please how can I do this.
- (void)viewDidLoad
{
URLs = [[NSMutableArray alloc]init];
for (NSString *path in latestiamge)
{
NSURL *URL = [NSURL URLWithString:path];
if (URL)
{
[URLs addObject:URL];
}
else
{
NSLog(#"'%#' is not a valid URL", path);
}
}
self.imageURLs = URLs;
myScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0.0, 84.0, 320.0, 840.0)];
myScrollView.delegate = self;
myScrollView.contentSize = CGSizeMake(320.0, 840.0);
myScrollView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:myScrollView];
float horizontal = 2.0;
float vertical = 2.0;
for(int i=0; i<[imageURLs count]; i++)
{
if((i%3) == 0 && i!=0)
{
horizontal = 5.0;
vertical = vertical + 100.0 + 5.0;
}
CGRect frame;
frame.size.width=100.0;
frame.size.height=100.0;
frame.origin.x=0;
frame.origin.y=0;
AsyncImageView *imageView = [[AsyncImageView alloc] initWithFrame:frame];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
imageView.tag = i;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:#selector(actionHandleTapOnImageView:)];
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:singleTap];
[myScrollView addSubview:imageView];
[myScrollView addSubview:imageView];
horizontal = horizontal + 100.0 + 5.0;
}
[myScrollView setContentSize:CGSizeMake(320.0, vertical + 3900.0)];
[super viewDidLoad];
}
Well there is a good and basic class you can use for downloading and displaying images asynchronously .
SDWebImage
Doing everything yourself as you currently are is more effort than is required and not good for memory management. Consider using a table or collection view to manage the scrolling so you don't have so many views loaded at the same time and so you don't need code for the full layout of everything.
You're already using AsyncImageView, it will work if you add a number of them to the cells you're going to display and configure them as requested by the delegate/dataSource methods.
You should also think about acting as the scroll view delegate and monitoring the scroll completion. If the user has scrolled to the current bottom, you could add a footer view with an activity indicator, start a load of the next page from the server and then reload the view and remove the footer when the new page is downloaded.
From what I can understand from your question, you want to create a image grid with three images in a row. But your approach is wrong...!
Do not use scrollView but use a UITableView. I think you can use UICollectionView if you are targeting iOS 6.0 or above.
Here is what you need to do :
Create custom UITableViewCell with number of images you need in a row. You can make this dynamic too by passing number of grid items you need while creating the cell and creating the and positioning those views in the cell as subviews.
Reuse the cells in the table to populate the grid.
You can cache images for better performance, I would suggest you to use SDWebImage
In cellForRowAtIndexPath you can configure all the gridItems.
Do you need more help...??
At this moment, my program looks like this:
As you can see, the square with the rounded rectangles is an image but it doesn't show very well and am not sure how to solve this... Here is the class: http://pastebin.com/QPXbG1uK
The background window gets added here:
UIImageView* background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"popupWindowBack.png"]] ;
background.center = CGPointMake(_bigPanelView.frame.size.width/2, _bigPanelView.frame.size.height/2);
[_bigPanelView addSubview: background];
Also what do I need to change if I want a simple view as the background instead of the image?
In Your place I would stop using Center coordinates and specifically set it's frame rectangle:
background.contentMode = UIViewContentModeScaleAspectFit;
background.frame = CGRectMake(10,10,_bigPanelView.frame.size.width-20, _bigPanelView.frame.size.height-20);
In this case - imageview will be 10 pix from top/left/right/bottom.
Remove this:
background.center = CGPointMake(_bigPanelView.frame.size.width/2, _bigPanelView.frame.size.height/2);
If you want to achieve your image fit your UIImageView try this:
background.contentMode = UIViewContentModeScaleAspectFit;
Also you need to set background frame to fit screen size, for example if you adding UIImageView in UIViewController class instance:
background.frame = self.view.frame;
i think your image size is larger then bigPanelView view . plz set the background frame size of the bigPanelView. like
background.frame = bigPanelView.view.frame;
I am trying to simulate the same behaviour as the defaults "Photos" application found on the iPhone OS 3.X-4.0.
Basically when the user selects multiple photos in the Album via the UIImagePickerController from the Image Library,an icon (tick mark) appears on the image to represent that the image has been selected by the user. How to implement this functionality.
Many thanks
create another UIImageView with the tickmark-image and add it as a subview to your selected UIImageView. Like this:
- (void)putCheckmarkOnImageView:(UIImageView *)anImageView {
UIImageView *newIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"checkmark.png"]];
newIV.tag = 42;
CGPoint newIVPosition = CGPointMake(anImageView.bounds.size.width - newIV.bounds.size.width,
anImageView.bounds.size.height - newIV.bounds.size.height);
CGRect newFrame = newIV.frame;
newFrame.origin = newIVPosition;
newIV.frame = newFrame;
[anImageView addSubview:newIV];
[newIV release];
}
- (void)removeCheckmarkOnImageView:(UIImageView *)anImageView {
[[anImageView viewWithTag:42] removeFromSuperview];
}
[_arrayOfCheckedPhotos addObject:anImageView.image]; // Same code, but add it to a mutable array
// this is assuming you want the array of images
Just put that line of code before the release in the comment above mine^ than later you can access all of the selected images, make the array a property so its easily accessible
and also in the removeCheckMark function say:
[_arrayOfCheckedPhotos removeObjectAtIndex:
I would like to move an imageView contained on a cell and it works but creating a new image at new position keeping old image (then two are shown). How could I remove old one?? used code:
UIImage *cellImage = [UIImage imageNamed:(#"%#", showIconName)];
UIImageView *imageViewToPutInCell = [[UIImageView alloc] initWithImage:cellImage];
imageViewToPutInCell.frame = CGRectMake(iconPos, 7, cellImage.size.width, cellImage.size.height);
[cell.contentView addSubview:imageViewToPutInCell];
every time that I reload tableView, it creates a new overlapped image.
[cell.contentView removeFromSuperview]; used before, removes it but then new image is not created.
There are a couple of ways to do this. Without subclassing, you could set the tag on your imageViewToPutInCell, then later on, use -[UIView viewWithTag:] to find and remove the view:
int imageViewTag = 1234;
[[cell.contentView viewWithTag: imageViewTag] removeFromSuperview];
imageViewToPutInCell.tag = imageViewTag;
...
i have one imageview in IB.i linked it perfectly in my view controller's IBoutlet
which is as IB_img .i have done in my viewdidload as
self.IB_img.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:#"img_1.jpg"],
[UIImage imageNamed:#"img_2.jpg"],nil];
self.IB_img.animationDuration = 1;
self.IB_img.animationRepeatCount = 0;
[self.IB_img startAnimating];
it is not working perfectly....image is not in screen..but if i do it in without IB,in other words dynamically...it works perfectly...any help please to do animation with IB ?
You would have not set the Mose of the imageView as in required format.
You can do it as:
Try to set the one of the animation images as the image of your image view in xib(temporarily).
then set the image view's mode as strecthtofit or whatever suits you. now remove the image. and build you will see the image in proper position.