弧,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
方法会返回一个结果。
我尝试过的事情:
- 在此特定文件上禁用 ARC
alloc] init]
在视图控制器上使用
编辑:我可能应该显示声明:
//MyViewController.h
@property (strong, nonatomic) IBOutlet UIScrollView* scroll;
...
//MyViewController.m
@synthesize scroll;