相关疑难解决方法(0)

使用UINavigationController在UIPageViewController中下载内容

更新2

我一直在使用4英寸设备在iOS模拟器中运行和测试我的应用程序.如果我使用3.5英寸设备运行,标签不会跳转.在我的.xib中,在Simulated Metrics下,我将它设置为Retina 4英寸全屏.知道为什么我只在4英寸设备上看到这个问题吗?

更新1

在IB中,如果我在模拟指标中选择"导航栏",我的标签仍然会跳转.我可以在第一个屏幕上正确呈现标签的唯一方法是不将导航控制器设置为我的窗口的根视图控制器.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

我的窗口的rootViewController被设置为一个UINavigationController,其rootViewController嵌入了一个UIPageViewController.

当我的应用加载时,会显示初始视图,其内容会向下推一点,大小与导航栏大致相同.当我滚动pageViewController时,内容会跳转到它在nib中的位置,而pageViewController加载的所有其他viewControllers都可以.

带导航控制器的uipageviewcontroller

在我的appDelegate中:

self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[ContainerViewController new]];
Run Code Online (Sandbox Code Playgroud)

在ContainerViewController中:

- (void)viewDidLoad {

    [super viewDidLoad];

    self.pvc = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
                                               navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                                                             options:nil];
    self.pvc.dataSource = self;
    self.pvc.delegate = self;
    DetailViewController *detail = [DetailViewController new];
    [self.pvc setViewControllers:@[detail]
                       direction:UIPageViewControllerNavigationDirectionForward
                        animated:false
                      completion:nil];

    [self addChildViewController:self.pvc];
    [self.view addSubview:self.pvc.view];
    [self.pvc didMoveToParentViewController:self];
}
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uinavigationcontroller ios uipageviewcontroller

60
推荐指数
3
解决办法
2万
查看次数

出现视图后应用iOS 8/XCode 6自动布局约束

我有一个与XCode 5和iOS 7一起工作得很好的项目,但是当我最近下载XCode 6时,我注意到autolayout出现了一些奇怪的行为.

我有一个故事板,其视图只有一个UIImageView和两个UILabel.使用UiPageViewController加载此视图.UIImageView在视图中水平和垂直居中,并且存在约束,指定两个标签与图像视图的距离.当故事板和自动布局值发生冲突时(例如,在故事板中,一个标签在图像视图上方20个像素但自动布局显示它应该在40像素以上),过去的自动布局值是在加载视图之前成功应用.因此,当视图第一次显示时,一切都在正确的位置.

现在使用iOS 8/XCode 6,我看到视图加载然后事情跳转到他们的最终自动布局位置.在模拟器和真实设备上,这种跳转对于最终用户来说是显而易见的,而且它真的很烦人.有没有办法回到过去的行为?据我所知,没有代码更改导致此问题.

xcode ios uipageviewcontroller autolayout xcode6

25
推荐指数
1
解决办法
8507
查看次数

UIPageViewController:子控制器在滚动期间忽略状态栏高度

我遇到了一些问题UIPageViewController.如果我滚动到了新的一页,新的视图控制器是落后的状态栏,而我在滚动.滚动后,视图控制器将自身置于状态栏下方.

我正在使用Storyboard(Universal).UIPageViewController有属性Extend Edges: Under Top Bars.我错过了什么?

在此输入图像描述

  • 设置automaticallyAdjustsScrollViewInsets为false不起作用
  • 使用edgesForExtendedLayout = UIRectEdge.None也没有用
  • 在这里找到一些开放的问题,但没有答案(链接)

UPDATE

跳跃的另一个原因是来自'Constraints'的'边缘'(在这里找到).如果使用约束,请确保取消选中边距(右对话框).您可以稍后在"实用程序"中将其删除(左侧对话框).检查两个连接的视图!

在此输入图像描述

statusbar ios uipageviewcontroller

8
推荐指数
1
解决办法
1656
查看次数

子视图控制器向下移动

我有一个TutorialsViewController,它以编程方式添加了PageViewController:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // Create page view controller
    self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"TutorialsPageViewController"];
    self.pageViewController.dataSource = self;

    TutorialsContentViewController *startingViewController = [self viewControllerAtIndex:0];

    NSArray *viewControllers = @[startingViewController];
    [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];

    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];
    [self.pageViewController didMoveToParentViewController:self]; 
}
Run Code Online (Sandbox Code Playgroud)

我使用委托方法将TutorialsContentViewController添加到PageViewController:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
    NSUInteger index = ((TutorialsContentViewController*) viewController).pageIndex;

    if ((index == 0) || (index == NSNotFound)) {
        return nil;
    }

    index--;
    return [self viewControllerAtIndex:index];
}

- (UIViewController …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uipageviewcontroller autolayout

7
推荐指数
1
解决办法
830
查看次数