English 中文(简体)
UIPageViewController: pageViewController:spineLocation for InterfaceOrientation: not known
原标题:UIPageViewController: pageViewController:spineLocationForInterfaceOrientation: not called

my spineLocationForInterfaceOrientation-method is not called; therefore, the spine is always on the left, but I would like to have it in the middle... what am I doing wrong?

if ([UIPageViewController class]) {
    self.pageViewController = [[UIPageViewController alloc]
        initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
        navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
    self.pageViewController.view.backgroundColor = [UIColor redColor];
    self.pageViewController.delegate = self;

    NotesPageController *notesPageController = [[NotesPageController alloc]
        initWithNibName:@"NotesPageController" bundle:nil];
    NSArray *pageViewControllers = [NSArray arrayWithObjects:notesPageController, nil];
    [self.pageViewController setViewControllers:pageViewControllers
        direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];

    self.pageViewController.dataSource = self;

    [self addChildViewController:self.pageViewController];

    [self.navigationController pushViewController:self.pageViewController animated:NO];
}

感谢很多!

最佳回答

您是否尝试人工确定间谍财产?

为确定间谍地点,将这种固定点之一划入一个NSNumber物体,并将其定为UIPageViewControllerOption SpineLocation值 词典中的关键关键内容是:方法。

Ref: rel=“noreferer”http://developer.apple.com/library/ios/#documentation/UIKit/Reference/PageViewControllerClassReferenceClassRef/UIPageViewControllerClassReferencesReferencea/

问题回答

各位是否认为控制者把上述守则适当列入观察控制人员等级? 先制定<条码> IDWindow.rootViewController,然后打电话addChildViewController: on each controller in the levels。 这对我来说是必要的,以便在改造一个SOS4时实现轮任和所谓的间谍职能。

<><>Edit>: 我先发现那里比这多。 Apple果使这一类别很难使用。 问题是,如果你想在另一时间创建UIPageViewController,与你首次打电话。 很可能,载有UIPageViewController的控制器将在initviewDidLoad上创建。 但是,现在真正的方向并不明确,因为人们总是在十字路口开始,如果真的是在地貌上,就会发出轮换通知。 因此,在大部分人即将创建UIPageViewController时,他们不知道该间谍的位置。

页: 1 这种做法的典型例子,例如 Apple果,但大多数 app子可能在以后的某个时候生动地装上内容。 如果您没有设置任何观点控制员,那么spineLocation for InterfaceOrientation就叫了。

因此,如果你已经建立了UIPageViewController,initWith TransitionStyle,你就会 st。 你可以确定间谍地点,你必须插入准确的观察控制器号码,以便你在知道真实方向时,如何启动这一类。 如果你确定错误的观察控制员人数,那就无益地在屏幕上显示任何情况。

I see two possible solutions:

  1. 浏览器在打电话<条码>后插入 du/ UIViewController。 在该地设一名观点控制员将使其能够对轮换活动做出回应,并将打电话到<条码>。

  2. 推迟创建UIPageViewController,直到你准备确定实际内容和真实情况。 这是我选择的。

Totumus Maximus提供的答案样本代码

NSDictionary *options =  [NSDictionary dictionaryWithObject:
 [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid]
                            forKey: UIPageViewControllerOptionSpineLocationKey];    
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options];

这里对我来说是有助益的。 我使用了“pple”页面访问模板所产生的缺省项目。 但是,当我在导航控制器内使用时,没有适当展示间谍,所以必须修改从视德洛德方法中可以称作的初始化法。

- (void)initializePageViewController
{
    int numberOfPagesPerScreen = 1;
    if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
      numberOfPagesPerScreen = 1;
    else
      numberOfPagesPerScreen = 2;       

    // for two-page layouts, we ll need to specify the spine location
    NSDictionary *pageViewOptions = nil;
    if(numberOfPagesPerScreen == 2)
      pageViewOptions = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid], UIPageViewControllerOptionSpineLocationKey, nil];  

    self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:pageViewOptions];
    self.pageViewController.delegate = self;

    NSMutableArray *pageViewControllers = [NSMutableArray array];

    for(int pageViewIdx = 0; pageViewIdx < numberOfPagesPerScreen; pageViewIdx++) {
      MyPageViewController *pageController = [self.modelController viewControllerAtIndex:pageViewIdx storyboard:self.storyboard];
      [pageViewControllers addObject:pageController];
    }
    [self.pageViewController setViewControllers:pageViewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];

    self.pageViewController.dataSource = self.modelController;

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

    // Set the page view controller s bounds using an inset rect so that self s view is visible around the edges of the pages.
    CGRect pageViewRect = self.view.bounds;
    pageViewRect = CGRectInset(pageViewRect, 40.0, 40.0);
    self.pageViewController.view.frame = pageViewRect;

    [self.pageViewController didMoveToParentViewController:self];

    // Add the page view controller s gesture recognizers to the book view controller s view so that the gestures are started more easily.
    self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;
}




相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...