1

I have dynamically added image view inside a scroll view

  for(NSDictionary *str in slideShowImages){

    UIImageView *image = [[UIImageView alloc ] initWithFrame:CGRectMake(x, 0, 200, 150)];
    NSString *ImageURL = [str objectForKey:@"imageLink"];
    NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:ImageURL]];
    image.image = [UIImage imageWithData:imageData];

            UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected:)  ];
            singleTap.numberOfTapsRequired = 1;
            image.userInteractionEnabled = YES;
            [image addGestureRecognizer:singleTap];

    [documentory addSubview:image];

    x += image.frame.size.width+ 5;
}

documentory.contentSize = CGSizeMake(x, documentory.frame.size.height);

when image view touch it call this event

-(void)tapDetected:{


}

i want to move to another uiview controller when the imageview touch i use story board and since the imageview added dynamically i don't have idea how to do this can anyone help me

PS is there a way that i can use

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {....} 

in here thank you

Kamal Upasena
  • 1,329
  • 4
  • 13
  • 38
  • Please check the answer for this question. http://stackoverflow.com/questions/8348109/how-can-i-manually-switch-between-uiviewcontrollers-in-storyboard. This may help u. – HRM Oct 31 '13 at 07:38

2 Answers2

0

If you want to programmatically invoke a push segue, you give the segue a "storyboard id" in Interface Builder and then you can:

[self performSegueWithIdentifier:"pushToMyVC" sender:self];

OR

If you want to push using navigation controller/ present view controller you can use

UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"DestinationController"];

and push/ present your controller

Aditya Deshmane
  • 4,676
  • 2
  • 29
  • 35
0

find a way to do that

Drag UIViewController and give a storyboard ID in this case i named as xxx after impliment the action method like below

-(void)tapDetected{
    NSLog(@"single Tap on imageview");
    UIStoryboard * storyboard = self.storyboard;

    destinationViewController * detail = [storyboard instantiateViewControllerWithIdentifier: @ "xxx"];

    [self.navigationController pushViewController: detail animated: YES];
}
Kamal Upasena
  • 1,329
  • 4
  • 13
  • 38