Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a UIImageView with touch to go to other ViewController?

I have a StoryBoard and a base ViewController include some images.

How I can touch an image of them to go to other ViewController linked that UIImageView by modal?

like image 811
Tom King Avatar asked Dec 19 '12 10:12

Tom King


2 Answers

create the new viewController drag a tap gesture recognizer to the first viewController

right click + drag from the gesture recognizer to the new viewController and you will see the option modal

right click + drag from the UIImageView to the gestureRecognizer and you will see the gestureRecognizer option select it and that's all

Make sure the UIImageView have the "User Iteraction Enabled" option ckecked

just added a sample project to my github

like image 137
jcesarmobile Avatar answered Oct 06 '22 02:10

jcesarmobile


You can try the following to move from one view controller to another:

[MyImageView.view removeFromSuperview];
[MyNewViewController.view addSubview:MyImageView.view];

If you wish to animate that change making it fly its way, you might need to create animation for MyImageView.view.frame from the old to the new view controller. For that you'll need to use methods like

CGRect fromFrame = [MyImageView.view convertRect:MyImageView.view.frame toView:MyOldViewController]
like image 27
demosten Avatar answered Oct 06 '22 01:10

demosten