iPad - 如何在启动时将 RootView 中的第一个单元格自动加载到 DetailView 中?
标题几乎说明了一切。我每隔几天就会回来尝试实现这一点,但我似乎无法让它发挥作用。我假设从启动时设置详细信息的代码位于 viewDidLoad 中,但此时我一无所知。
非常感谢任何帮助。
——泰勒
The title pretty much asks it all. I've been coming back and trying to implement this every few days, but I cant seem to get it to work. I'd assume the code to set the detailItem from launch goes in the viewDidLoad, but at this point I am clueless.
Any help is greatly appreciated.
--Tyler
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
selectRowAtIndexPath
委托:当然,将
[NSIndexPath indexPathForRow:0 inSection:0]
替换为您要自动设置的部分/行。您可以将其放入
viewDidLoad
或viewWillAppear:
委托中。另外,请确保您在标头中定义了
tblMyTable
(或任何您为表命名的内容),通过 Interface Builder 将其连接起来(如果您使用的是自定义 XIB),并在 .m 中使用@synthesize
并且在使用该方法时应调用
didSelectRowAtIndex:
,所以只要你的detailItem代码在didSelectRowAtIndex
中,你就应该没问题。You can use the
selectRowAtIndexPath
delegate:Of course, replace
[NSIndexPath indexPathForRow:0 inSection:0]
with the section / row that you want to automatically set.You can either put this in your
viewDidLoad
orviewWillAppear:
delegate.Also, make sure that you define your
tblMyTable
(or whatever you have named your table) in your header, hooked it up through Interface Builder (if your using a custom XIB), and use@synthesize
in your .mAnd the
didSelectRowAtIndex:
should be called when you use that method, so as long as your detailItem code is indidSelectRowAtIndex
, you should be good.