在解除与uisplitviewcontroller结合使用的模态视图后出现问题 [英] Problem after dismissing a modal view used in conjunction with a uisplitviewcontroller

查看:105
本文介绍了在解除与uisplitviewcontroller结合使用的模态视图后出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解为什么会发生以下情况(以及如何解决)。

I'm having a hard time understanding why the following is happening (and how to fix it).

我使用拆分视图创建了一个应用程序基于应用程序。

I've created an application using the split-view based application.

我添加了一个名为showTheModal的UiBarButtonItem,它调用RootViewController.m中找到的方法:

I've added a UiBarButtonItem called showTheModal which calls this method found in RootViewController.m:

- (IBAction)showTheModal:(id)sender {
theModalController.modalPresentationStyle = UIModalPresentationFullScreen;
theModalController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:theModalController animated:YES];

if ([detailViewController popoverController] != nil)
    [[detailViewController popoverController] dismissPopoverAnimated:YES];

BarButtonItem当然显示在默认根控制器的底部(左侧的)横向分割视图)或弹出窗口底部(如果是横向)。

The BarButtonItem of course, is shown at the bottom of the Default Root Controller (left side of the of the split view in landscape) or at the bottom of the popup (if in landscape).

模态视图被放置在工具栏中的按钮解除。它调用以下内容:

The modal view is dismissed by a button placed in a toolbar. It calls the following:

[self dismissModalViewControllerAnimated: YES];

我遇到的问题是如果在模态启动时旋转屏幕。以下是在不同场景中发生的事情(start是指showTheModal按钮被击中时的方向,end指的是当我按下dismissModal按钮时的方向)。

The problem I'm having is if rotate the screen, while the modal is up. Here is what happens in different scenarios (start refers to the orientation when the showTheModal button is hit, end refers to the orientation when I hit the dismissModal button).

1)开始景观,结束景观:一切都很好。在RootViewController中没有调用willHideViewController和willShowViewController方法(如预期的那样)

1)Start landscape, end landscape: Everything appears fine. willHideViewController and willShowViewController methods are not called in the RootViewController (as expected)

2)启动横向,结束肖像:UI显示正常。 willHideViewController运行TWICE(为什么?)

2) Start landscape, end portrait: UI appears fine. willHideViewController is run TWICE (WHY?)

3)开始肖像,结束肖像:UI显示正常。 willHideViewController运行一次(如预期的那样)

3) Start portrait, end portrait: UI appears fine. willHideViewController is run once (as expected)

4)启动纵向,结束横向:根列表按钮保留在详细视图中(拆分视图的右侧)。 willHideViewController和willShowViewController都没有被调用(为什么?)

4) Start portrait, end landscape: The 'Root List' button remains in the detail view (right side of the split view. Neither willHideViewController and willShowViewController are invoked (WHY??)

为什么#2和#4的表现不符合预期的方式呢?

Any thoughts as to why #2 and #4 don't behave quite the expected way?

推荐答案

不幸的是,这不是一个错误。它似乎是一种预期的行为。

Unfortunately this is not a bug. It appears to be an expected behavior.

我在iOS版的iOS发行说明中,在注释和已知问题部分中找到了这个:

I found this in iOS Release Notes for iOS 5.0, in "Notes and Known Issues" section:


iOS 5中的旋转回调未应用查看控制器
是通过全屏显示的。这意味着如果您的代码
在另一个视图控制器上显示视图控制器,然后
用户随后将设备旋转到不同的方向,在
解雇时,基础控制器(即呈现控制器)将为
没有收到任何轮换回调。但请注意,当
重新显示时,呈现的
控制器将收到viewWillLayoutSubviews调用,并且可以从
查询此方法的interfaceOrientation属性,并用于正确布局控制器。

Rotation callbacks in iOS 5 are not applied to view controllers that are presented over a full screen. What this means is that if your code presents a view controller over another view controller, and then the user subsequently rotates the device to a different orientation, upon dismissal, the underlying controller (i.e. presenting controller) will not receive any rotation callbacks. Note however that the presenting controller will receive a viewWillLayoutSubviews call when it is redisplayed, and the interfaceOrientation property can be queried from this method and used to lay out the controller correctly.

这篇关于在解除与uisplitviewcontroller结合使用的模态视图后出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆