0

アプリを作成しようとしています。

3 つのメイン ページが必要です。だから私は PageControl でこれを達成することを考えました。

3 つのビューを作成しましたが、この PageControl の実装に行き詰まっています。

私が見ることができる良いチュートリアルやサンプルコードはありますか(ドイツ語でもかまいません)?

ありがとう、マイケル

4

1 に答える 1

12

使い方の簡単なアイデアを次に示します。

PageController.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

PageController.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
于 2010-02-09T17:00:26.167 に答える