1

それで、

カスタムアプリケーションワークフローでを使用しようとしていUIPageViewControllerますが、ドキュメントで推奨されているとおりに実装しています。

 self.pageViewController = [[[UIPageViewController alloc]  initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
                                                            navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil] autorelease]; 

//calls setViewControllers:direction:animated:completion with valid UIViewControllers
[self setupPagesWithIndex:0]; 

self.pageViewController.delegate = self;
self.pageViewController.dataSource = self;

self.view.frame = CGRectMake(0, 0, 1024, 768);

self.pageViewController.view.backgroundColor = [UIColor grayColor];

ここで、ビューコントローラを設定します...

- (void) setupPagesWithIndex:(NSInteger) index
{
    UIViewController* vc1 = [self uicontrollerForIndex:index];
    UIViewController* vc2 = [self uicontrollerForIndex:index+1];
    [self.pageViewController setViewControllers:[NSArray arrayWithObjects:vc1,vc2, nil] 
                                      direction:UIPageViewControllerNavigationDirectionForward 
                                       animated:NO 
                                     completion:nil];
}

画面に表示されるのは灰色の背景色だけです。が有効で、フレームが良好であることを確認しました。また、何かUIViewControllersが見えるように背景色を付けました。

これが、UIPageViewControllerを画面に追加する方法です。

 [[self rootViewController] addChildViewController:self.pageViewController];
 [[self rootViewController].view addSubview:self.pageViewController.view];

[self rootViewController]アプリケーションのrootViewControllerを返します。

適用した背景色が見えるので、ビューは確実に表示されます...ただし、UIPageViewControllerは完全に空白です。

私はすべてのデータソースとデリゲートメソッドを実装し、プロトコルを採用しました。彼らは呼ばれることさえありません!

私の質問は; プログラムですべてを行うときにUIPageViewControllerがページを表示するためのすべての要件は何ですか?

編集#1、リクエストごと:このクラスは、私自身のアプリケーション構築フレームワーク内のUIPageViewControllerのコントローラーです。私は今、コントローラーにページを構築する2つの方法を提供しています。画像名または一種のアセットキーからです。いずれの場合も、最終的にはUIViewControllerでラップしたビューを返します。

ビューコントローラーを作成します

UIViewController* vc = [[[PageTest alloc] initWithNibName:@"PageTest" bundle:nil] autorelease];

'PageTest'は、対応するペン先を持つUIViewControllerであり、自動生成された設定を除いて空白です。次に、カスタムビューをサブビューとしてこのビューコントローラに追加します。これは、uicontrollerForIndexから返されるものです。

編集#2、さらなる発見

本のフリッパーを表示する方法を見つけました。1つのViewControllerで初期化すると、ブックフリッパーが表示されます。2つのViewControllerが完全に異なるクラスであるかどうかは関係ありません。2つでViewControllersを設定すると、何も表示されません。

UIPageViewControllerSpineLocationMidデリゲートメソッドに戻ると

- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation

その後、ローテーションすると、アプリは識別可能なバックトレースなしでクラッシュします。

4

1 に答える 1

2

とともに、

 - (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation

メソッドの場合、をsetViewControllers返す前に呼び出す必要がありますspineLocation

于 2012-02-10T22:19:38.163 に答える