开发者

Push next viewcontroller from a subview

开发者 https://www.devze.com 2023-04-03 01:21 出处:网络
Is it possible to push a viewcontroller from a subview? I have a subview of (thumbnail) images, horizontally scrolling. I want each image to be a button, and when pressed to push a view controller (of

Is it possible to push a viewcontroller from a subview? I have a subview of (thumbnail) images, horizontally scrolling. I want each image to be a button, and when pressed to push a view controller (of the lar开发者_StackOverflow社区ge photos). Obviously this needs to be done from the main view in which the subview resides.

I tried just allocating the large photo view controller and pushing it, but that went kaboom.


Yes. I suggest you have an IBAction method that takes care of the pushing. Wire up all of your photos to that same method, on IB or programmatically.The method would be in your Main View.

It would look something like this:

- (IBAction)anImageWasPressed:(UIButton *)sender
{

PhotoDetailViewController *pdvc = [[PhotoDetailViewController alloc] init];
[self.navigationController pushViewController:pdvc animated:YES];
[pdvc release];

}

You can pass the image to the new view controller in many ways. I think the best one is to have a @Property UIImage that you can set before pushing it.

0

精彩评论

暂无评论...
验证码 换一张
取 消