UINavigationController 中的向后转换错误 +横向的 UITableViewController
我正在调用 UINavigationController 并通常允许它使用任何主要方向:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
BOOL isAllowed;
if ([allowedOrientations isEqualToString:@"portrait"]) {
isAllowed = (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
} else if ([allowedOrientations isEqualToString:@"landscape"]) {
isAllowed = (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
} else {
isAllowed = YES;
}
return isAllowed;
}
从那里我调用 UITableViewController:
myTable = [[SimpleDocViewerTable alloc] initWithFrame:thisFrame];
self = [super initWithRootViewController:myTable];
其中:
@interface SimpleDocViewerTable : UITableViewController {
表视图控制器和导航控制器大多看起来正确集成。当我将新页面推到导航控制器上时,无论我使用哪个方向,它都会正确地从右向左滚动:
SimpleDocPageVC *thisVC = [[SimpleDocPageVC alloc] initWithView:docView];
thisVC.title = [[[tableEntries objectAtIndex:indexPath.section]
objectAtIndex:indexPath.row] objectForKey:@"title"];
[self.navigationController pushViewController:thisVC animated:YES];
但是,当我退出该推送的页面时,如果 iPhone 处于横向模式,它会从下到上滚动,而不是从右到左。
popViewController 都在生成的自动“后退”按钮中神奇地得到了处理,所以它应该做正确的事情......但事实并非如此。
I'm calling up a UINavigationController and usually allowing it to use any major orientation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
BOOL isAllowed;
if ([allowedOrientations isEqualToString:@"portrait"]) {
isAllowed = (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
} else if ([allowedOrientations isEqualToString:@"landscape"]) {
isAllowed = (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
} else {
isAllowed = YES;
}
return isAllowed;
}
From there I call a UITableViewController:
myTable = [[SimpleDocViewerTable alloc] initWithFrame:thisFrame];
self = [super initWithRootViewController:myTable];
Where:
@interface SimpleDocViewerTable : UITableViewController {
The table view controller and navigation controller mostly seem integrated correctly. When I push a new page onto the navigation controller, it correctly scrolls right to left, no matter which orientation I'm using:
SimpleDocPageVC *thisVC = [[SimpleDocPageVC alloc] initWithView:docView];
thisVC.title = [[[tableEntries objectAtIndex:indexPath.section]
objectAtIndex:indexPath.row] objectForKey:@"title"];
[self.navigationController pushViewController:thisVC animated:YES];
However, when I exit that pushed page, if the iPhone is in landscape mode, it scrolls bottom to top, rather than right to left.
The popViewController is all taken care of magically within the automatic "back" button that's generated, so it should be doing the right thing ... but doesn't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否您的控制器之一(
SimpleDocViewerTable
或SimpleDocPageVC
)不支持shouldAutorotateToInterfaceOrientation
中的两个方向?Could it be that one of your controllers (
SimpleDocViewerTable
, orSimpleDocPageVC
) does not support both orientation inshouldAutorotateToInterfaceOrientation
?