我想让UIViewController视图类成为一个scrollView。我该怎么做?
答案 0 :(得分:2)
只需在UIScrollView
方法中将视图初始化为-loadView
(您需要覆盖它)。
- (void)loadView {
self.view = [[UIScrollView alloc] initWithFrame:...];
// do other init stuff;
}
您无需致电[super loadView]
,它只会分配默认UIView
个实例,并将其分配给view
。
答案 1 :(得分:1)
为什么不:
@implementation MyScrollViewController
...
...
-(void)viewDidLoad
{
[super viewDidLoad];
//configure my scrollview (self.view). This may require you to cast your self.view to UIScrollView.
}
-(void)loadView
{
UIScrollView *sv = [UIScrollView alloc] init] autorelease]; //will be retained by self.view
self.view = sv ;
}
...
...
@end