ARC,iOS 5,XCode 4.2
我正在尝试使用页面控件(类似于主屏幕)实现分页滚动视图,我似乎无法让它工作。相关代码是:
- (void)viewDidLoad
{
[super viewDidLoad];
[scroll setDelegate:self];
[scroll setContentSize:CGSizeMake(2 * [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
[scroll setPagingEnabled:YES];
pageControl.currentPage = 0;
pageControl.numberOfPages = 2;
UIView* view = [[self.storyboard instantiateViewControllerWithIdentifier:@"VALID_ID_1"] view];
view.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);
[scroll addSubview:view];
UIView *aView = [[self.storyboard instantiateViewControllerWithIdentifier:@"VALID_ID_2"] view];
aView.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);
[scroll addSubview:aView];
}
调用instantiateViewControllerWithIdentifier
方法会返回结果。
我尝试过的事情:
alloc] init]
编辑:我应该展示声明:
//MyViewController.h
@property (strong, nonatomic) IBOutlet UIScrollView* scroll;
...
//MyViewController.m
@synthesize scroll;
答案 0 :(得分:0)
最有可能的是,scroll
是nil
。请检查..!