开发者

Push next viewcontroller from a subview

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜