How to show XML parsed images by using Tap gestures in iphone? - iphone

I am making an App in which i am parsing an XML and storing the url of images in an array.
Now i have to show all that images on next View Controller using Tap Gestures and when i click on images i have some action to perform. So please can anyone help me regarding that?
I can provide the code what i have written if anyone want or tell me some tutorial as i am not able to get it from developer sites.

Load your images into UIImage objects like so:
UIImage *imageFromUrl = [UIImage imageWithContentsOfFile:[NSURL fileURLWithPath:url]];
Then, place them into UIImageView objects wherever you need them. The next thing you should do is add a TapGestureRecognizer:
UIImageView *imgView = [[UIImageView alloc] initWithImage:imageFromUrl];
UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(action)];
[imgView addGestureRecognizer:tgr];
[tgr release];
//Do the rest of your operations here, don't forget to release the UIImageView
And that's it. Do whatever you need in the "action" method that will get called on your ViewController

For that you have to use TapDetactingimgView.
In that view you get scroll,single tap & double tap event.By that you can scroll image & able to tap on that image.
for that Visit : https://bitbucket.org/billgarrison/panzoomimagedemo/src/34671df61417/Classes/TapDetectingImageView.m

Related

Creating Photo library like iPhone, but UIImage tap event handler not working

Hi i am new to iOS programming.
I need to create an photo library like iPhone native photo app. I have found a library MWPhotoBrowser
that provides nearly same UI for photo browsing and its perfect for my requirement. But now i have 2 problems
First is that i need to create a grid layout with thumbnails. Clicking on an thumbnail should display image in full screen with browsing functionality. I tried to dynamically adding UIImageViews in UIScrollView, but UIScrollView is not scrolling and images are going out of screen.
Second is i could not get any tap handler on UIImageView so that i can open an image in full screen.
Looking for some tips here, i am really stuck here.
You can give a shot to this library, it has both features which you are looking for.
https://github.com/gdavis/FGallery-iPhone
Hope it helps :)
For ScrollView scrolling issue you have to increase scrlViewMain.contentSize dynamically. Create a for loop and put bellow code at the end of loop.
scrlViewMain.contentSize = CGSizeMake(0, incermentAsPerYourNeed);
For the tapping issue you have to add TapGesture. Put bellow code when your ImageView creates.
imgView.tag = giveAsPerYourRecordsID;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleImageTap:)];
tap.cancelsTouchesInView = YES;
tap.numberOfTapsRequired = 1;
tap.delegate = self;
[imgView addGestureRecognizer:tap];
[tap release];
And bellow your catch method for tapping.
- (void) handleImageTap:(UIGestureRecognizer *)gestureRecognizer {
UIImageView *tmpImgView = (UIImageView *)gestureRecognizer.view;
}
I have also developed similar functionality a few days ago for my project.
For tap issue you should use UIButton instead of UIImageView, it gives you tap action event. For Scrollview not scrolling, just make sure you update contentSize property of UIScrollView, otherwise it would not scroll according to your subviews.

Expandable UITextField with option for inserting image

I want to make the same view as iPhone default message app here is the screen shot what i want to do so can any one help me for suggesting 3rd party control or technique for making this kind of control in my app
Here is the Source code you wanted for the Growing TextField , although it doesn't contains the image button but you can easily customize it to fullfil your requirement
https://github.com/HansPinckaers/GrowingTextView
Hope it will help you.
You can add the image view as a subView of UITextView.
Create an imageView with image:
UIImageView *imageView = [[UIImageView alloc] initWithImage:yourImage];
[imageView setFrame:yourFrame];
[yourTextView addSubview:imageView];
and can use third party library for this Here
Hope it helps you.
you can directly add your image view on text view.
Tried this one
UIImageView * image=[[UIImageView alloc]initWithImage:[UIImage imageNamed:#"xyz.png"]];
[textview addSubview:image];
this will really helpful.

Summoning stored images

I have images in my iphone application I would like to summon when needed.
The idea is when the user takes a photo and it's loaded on the imageview, he or she will be able to call out my custom images that's preloaded in the app. The user can then move the custom image around their original photo.
My question is, how do I implement that? How do I store custom image for the user to call out later on?
Thanks.
So you have image files imported into your project and you'd like to show them on-screen?
Say you want to display the image "paintcan.jpg". All you have to do is create an image view, set its image, and add it to the main view.
UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)] autorelease];
imageView.image = [UIImage imageNamed:#"paintcan"];
[self.view addSubview:imageView];

Using Image to Perform an Action instead of Button in iPhone Applciation

How can i use image to Perform an Action instead of Using Button or adding an image to Button, just wanna click button and perform particular set of instructions.
(Thanks in Advance)
Use a UIGestureRecogniser.
// IF your image view is called myImage
UIImageView *myImage = ...;
// Add a tap gesture recogniser
UITapGestureRecogniser *g = [[UITapGestureRecogniser alloc] initWithTarget:self action:#selector(imagePressed:)];
[myImage addGestureRecogniser:g];
[g release];
When your image is tapped, this method will get called
- (void)imagePressed:(UIGestureRecogniser *)recogniser {
NSLog(#"%#", recogniser);
}
Why don't you want to use a UIButton - it inherits from UIControl and has a lot of code that you probably don't even know exists? And it can just contain an image so it would look exactly the same?
Well, the pro about using UIButtons is that it got all touch events built right in. You can use UIImageViews, but you'll need to subclass them, while in most situations, a UIButton using a background-image would just fit.

iPhone - user interaction with programmatically added UIImageView

So I'm trying to add UIImageViews programatically (in this case I don't have the option of doing it in IB) and I want to be able to refer to them and manipulate them in the -touchesBegan and -touchesMoved methods.
I've added the images like this:
UIImageView *newPiece = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:#"%d.png", [piece tag]]]];
newPiece.frame = CGRectMake(pieceX, pieceY, pieceW, pieceH);
[newPiece setCenter:CGPointMake(pieceX, pieceY)];
[newPiece setTag:[piece tag]];
[[self view] addSubview:newPiece];
[newPiece release];
And note, many of these newPiece's are added programmatically, because the method that this is in is called more than once, so the images have different centers and images and stuff, so would I need an array to hold all of them?
Thanks
NSMutableArray would probably suit your needs.
Check this very detailed post. It's precisely about handling several programatically added UIImageViews and it worked nice for me.
Create multiple views and make the touched view follow the users touch
Best luck.