質問

私は使用しています UIPageViewController 初めて。もちろん、iOS5であり、私はアークに満足しています。私は いいえ ストーリーボードの使用。

私が見るすべての断片的な例では、 UIPageViewController 画面を「所有」しないでください。それは常に他のビューコントローラーの子供です。これは要件ですか?私はそれを私のアプリのルートコントローラーにしたいのですが、一般的に行われているのと同じように UINavigationController. 。私はそれをプログラムですべて設定しようとしていますが、私が得るのは空のページビューコントローラーだけで、コンテンツが含まれていません。

アプリの開始方法は次のとおりです(こちらのすべてのコードは私のアプリDelegateクラスにあります):

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    [self configureLoggers];
    [self applyAppearanceProxySettings];
    [self configureDataStore];
    [self configureNavigationController];
    [self configurePageController];    // <-- this is where we do the page view controller setup, shown next.

    self.window.rootViewController = self.pageController;
    [self.window makeKeyAndVisible];

    log4Info(@"Application completed launching.");

    return YES;
}

そして、上記のコードに記載されているその方法は、ページビューコントローラーのセットアップを行います。

- (void)configurePageController {
    CCFrontCoverViewController *frontCoverViewController = [[CCFrontCoverViewController alloc] initWithNibName:nil bundle:nil];

    NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:UIPageViewControllerSpineLocationMin]
                                                    forKey:UIPageViewControllerOptionSpineLocationKey];

    self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
                                                      navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                                                                    options:options];

    self.pageController.delegate = self;
    self.pageController.dataSource = self;
    self.pageController.view.backgroundColor = [UIColor redColor]; // So we know we're missing content because red shows through.

    NSArray *pageViewControllers = [NSArray arrayWithObjects:frontCoverViewController, self.navigationController, nil];
    [self.pageController setViewControllers:pageViewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
}

また、2つのデータソースコールバックメソッドにログを入れましたが、呼び出されません。

これが実行されると、空白の赤い画面が表示されます。繰り返しますが、ストーリーボードは関係ありません。何が足りないの?

役に立ちましたか?

解決

私はaを使用することができます UIPageViewController サンプルプロジェクトのルートビューコントローラーとして、

  • UIPageViewController 有効な脊椎の位置で適切に初期化されます。
  • UIPageViewController's doubleSided プロパティが設定されています(背骨の位置と一致)。
  • UIPageViewController's viewControllers 配列は設定されています(繰り返しますが、背骨の位置と一致し、 doubleSided 財産)。

設定していないようです doubleSidedYES あなたのコードで(あなたのため viewControllers 配列には2つのアイテムがあります)。設定する前にそれを追加します viewControllers 配列はあなたの問題を修正しますか?

編集: 後世のために、 uipageviewcontrollerドキュメント の説明にはチャートがあります setViewControllers:direction:animation:completion: 脊椎の位置とすべての有効な組み合わせに許可された視聴コントローラーの数を示す方法と doubleSided.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top