我有一個在兩個視圖之間切換的滾動視圖。這兩個視圖在viewDidLoad中設置。我希望有一個頁面控件在選擇相應視圖時進行切換。簡單頁面控件
我看過的所有教程都很複雜。
- (void)viewDidLoad {
[super viewDidLoad];
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, scrollView.frame.size.height);
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.scrollsToTop = NO;
scrollView.delegate = self;
CGRect pageFrame = CGRectMake(0, 0, scrollView.bounds.size.width, scrollView.bounds.size.height);
scrollView.contentSize = CGSizeMake(pageFrame.size.width * 2, pageFrame.size.height);
scrollView.pagingEnabled = YES;
view1.frame = pageFrame;
[scrollView addSubview:view1];
pageFrame.origin.x += pageFrame.size.width;
view2.frame = pageFrame;
[scrollView addSubview:view2];
}
- (IBAction)changePage:(id)sender {
}
這工作完美!非常感謝。 – Vikings