选项卡切换方法的区别
这两行代码有区别吗?
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:1];
我的
self.tabBarController.selectedIndex = 1;
应用程序刚刚在顶部语句上崩溃,因此可能存在一些内存问题。一种方法相对于另一种方法有什么优点吗?
Is there a difference between these two lines of code?
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:1];
and
self.tabBarController.selectedIndex = 1;
My app just crashed on the top statement so it might have some memory issues. Are there any advantages of one method over the other?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,设置 selectedIndex 属性将执行与第一个语句类似的操作,但它可能会执行更多检查。当 tabBar 中有超过 5 个控制器时,即当有“更多”选项卡时,会有差异。这是文档告诉我们的:
Actually, setting the selectedIndex property will do something similar as in your first statement, but it will probably do some more checking. There will be a difference when there are more than 5 controllers in your tabBar, so when there is a 'More' tab. This is what the documentation tells us: