开发者

iPad - How do I load the first cell from the RootView automatically into the DetailView upon launch?

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. 开发者_StackOverflow中文版

Any help is greatly appreciated.

--Tyler


You can use the selectRowAtIndexPath delegate:

[tblMyTable selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:0];

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 or viewWillAppear: 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 .m

And the didSelectRowAtIndex: should be called when you use that method, so as long as your detailItem code is in didSelectRowAtIndex, you should be good.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜