iPhone 无法在 TabBar 控制器中旋转视图
我正在开发一个由 TabBar 控制器组成的应用程序。 在其选项卡中,我有一个 UITableViewController 的子类,在此列表中,我在第一个单元格中有一个 Core-plot 图形,在接下来的 4 个单元格中有一些其他数据。 当我在 shouldAutorotateToInterfaceOrientation 方法中返回 YES 时,我希望列表视图会自动调整大小,但是......什么也没有。 当我在 willRotateToInterfaceOrientation 方法中添加一些日志时,它们不会显示。 有什么我错过的吗? 多谢, 吕克
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
NSLog(@"Orientation");
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
NSLog(@"Rotating");
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
NSLog(@"view land:%@", self.view);
}
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
NSLog(@"view portrait:%@", self.view);
}
}
I am working on an application that consists of a TabBar controller.
Within on of its tab, I have a subclass of UITableViewController, within this list I have a Core-plot graph in the first cell and some other data in the 4 following cells.
When I return YES in the shouldAutorotateToInterfaceOrientation method, I would expect the autoresizing of the list view to happen, but... nothing.
When I add some log in the willRotateToInterfaceOrientation method, they are not displayed.
Is there something I missed ?
Thanks a lot,
Luc
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
NSLog(@"Orientation");
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
NSLog(@"Rotating");
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
NSLog(@"view land:%@", self.view);
}
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
NSLog(@"view portrait:%@", self.view);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,除非您继承
UITabBarController
并正确重写其shouldAutorotateToInterfaceOrientation:
方法,否则它将无法工作。请参阅我的问题和相关答案。
Yes, it won't work unless you subclass
UITabBarController
and override itsshouldAutorotateToInterfaceOrientation:
method correctly.See my question here and related answers.