开发者

UIViewControllers in UIScrollView?

I have a design question. I have a scroll view that I want to use as a means of navigation. I.e. the user can slide between screens. At present, I am creating view controllers and putting their views directly on the scroll view:

aViewController.view.frame=CGRectMake(0,0,320,200);    
[self.myScrollView addSubview:[aViewController view]]

Etc, for all 3 view controllers.

I know this isn't best practice. But I can't think of any other way of doing it. Ideally I would like开发者_如何学C to get the same behaviour as a navigation controller except the fact that I'll be using a scroll view. Any help would be greatly appreciated.


You have to be aware that this breaks certain UIViewController behaviors because these child view controllers do not get informed about interface rotation events and their viewWill/Did(Dis)Appear: methods will not work.

The alternative (until iOS 4.x at least) is to not use UIViewController subclasses for these subviews. You could easily create your own custom controller class (derived from NSObject) to manage a child view.

It's debatable whether that approach makes it easier overall, though.


I'm guessing what you're trying to achieve is something similar to this app?

http://itunes.apple.com/us/app/fanhattan-for-ipad/id436928538?mt=8

This app works in the same manner, using a scroll view for navigation. You can analyze that app, you'd get some ideas from it, i'm sure.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜