我即将创建一个应用程序。
它应该有 3 个主要页面。所以我想用 PageControl 来实现这一点。
我创建了 3 个视图,现在我被困在这个 PageControl 的实现上。
有没有人可以看的好教程或示例代码(也可以是德语)?
谢谢,迈克尔
我即将创建一个应用程序。
它应该有 3 个主要页面。所以我想用 PageControl 来实现这一点。
我创建了 3 个视图,现在我被困在这个 PageControl 的实现上。
有没有人可以看的好教程或示例代码(也可以是德语)?
谢谢,迈克尔
这是一个关于如何使用它的简单想法。
页面控制器.h:
#import <UIKit/UIKit.h>
@interface PageController : UIViewController {
NSArray * views;
UIPageControl *pageControl;
}
@property (nonatomic, retain) IBOutlet UIPageControl * pageControl;
- (IBAction) changePage:(id)sender;
- (void) animateToView:(UIView *)newView;
@end
页面控制器.m:
#import "PageController.h"
@implementation PageController
- (void)viewDidLoad {
[super viewDidLoad];
pageControl.numberOfPages = [views count];
pageControl.currentPage = 0;
// Either wire this up in Interface Builder or do it here.
[pageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
}
- (IBAction) changePage:(id)sender {
UIView * newView = [views objectAtIndex:[pageControl currentPage]];
[self animateToView:newView];
}
- (void) animateToView:(UIView *)newView {
// You'd have to implement this yourself
}
@end