gpt4 book ai didi

iphone - UINavigationController 中横向和纵向模式导航的最佳实践

转载 作者:行者123 更新时间:2023-12-01 19:27:20 26 4
gpt4 key购买 nike

我正在开发一个支持横向和纵向的 iPad 应用程序。我的 rootviewController 有两个不同的 nib 文件。这是问题的场景-
1.纵向模式从 Root View 中选择一个项目,纵向推送下一个 View 。
2.旋转设备
3.按导航栏上的返回按钮
从堆栈加载的 View 是rootViewController 的肖像 View 。虽然设备仍处于横向模式。
请提出解决上述问题的解决方案。
此外,请建议在处理设备旋转时要遵循的最佳做法。

最佳答案

在以下方法中使用通知并在中设置坐标收到旋转 方法。

-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

}

-(void)viewWillDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}

例如在 收到旋转 您可以将 tableview 的坐标设置为:
if (orientation == UIDeviceOrientationLandscapeLeft||orientation==UIDeviceOrientationLandscapeRight)
{
[tblView reloadData];
tableX=70.0;

}
else
{
[tblView reloadData];
tableX=48.0;
}

也可调用 接收旋转 在 viewDidLoad 中是 非常重要的。

关于iphone - UINavigationController 中横向和纵向模式导航的最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6276776/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com