2012-10-16 12 views
16

私はUIPageControllerを使用して、異なるコントローラ間を移動しています。今度はその下にドットを追加したいので、ユーザーはどのコントローラーにいるかを見ることができます。これはUIPageControlによって達成されます。これらの2つを組み合わせる簡単な方法はありますか? UIPageViewController.hの底(iOS6 +)からUIPageControllerとUIPageControlを組み合わせていますか?

答えて

27

両方の方法が実装されている場合、ページインジケータが表示されるようになり、遷移スタイル「はUIPageViewControllerTransitionStyleScroll」は、ナビゲーション配向「UIPageViewControllerNavigationOrientationHorizo​​ntal」です。 両方のメソッドが 'setViewControllers:...'呼び出しに応答して呼び出されますが、プレゼンテーションインデックスはジェスチャー駆動のナビゲーションの場合に自動的に更新されます。

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController NS_AVAILABLE_IOS(6_0); // The number of items reflected in the page indicator. 
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController NS_AVAILABLE_IOS(6_0); // The selected item reflected in the page indicator. 

そうでなければ、私はあなたのUIPageViewControllerUIPageControlを追加して、基本的には同期でそれらを保つためにそれらを一緒に結び付けるために必要だと思う...しかし、あなたはすべて手動で同点を行う必要があります。

+0

現在のページを手動で設定する方法 –

+0

http://stackoverflow.com/questions/8400870/uipageviewcontroller-return-the-current-visible-viewはおそらくあなたが探しているものですか? –

10

Xcodeのページベースアプリケーションテンプレートを使用している場合は、 属性インスペクタに移動し、TransitonスタイルプロパティをScrollに設定します。

とアプリケーションAppDelegate.mファイルに移動し、Xcodeのベースページに対して

UIPageControl *pageControl = [UIPageControl appearance]; 
    pageControl.pageIndicatorTintColor = [UIColor lightGrayColor]; 
    pageControl.currentPageIndicatorTintColor = [UIColor blackColor]; 
    pageControl.backgroundColor = [UIColor whiteColor]; 

ため色合いの色を設定だけで、その色が白に設定されているそのすでにiOSの6、iOSの7用のテンプレート。

関連する問題