如何在默认情况下选择UITableViewCell? [英] How do I select a UITableViewCell by default?
本文介绍了如何在默认情况下选择UITableViewCell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个 UITableView
,并且想要一个特定的 UITableViewCell
出现选择(蓝色)加载。
I have created a UITableView
and would like a specific UITableViewCell
to appear selected (blue) when the view is loaded.
推荐答案
-(void)viewWillAppear:(BOOL)animated {
// assuming you had the table view wired to IBOutlet myTableView
// and that you wanted to select the first item in the first section
[myTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
animated:NO
scrollPosition:UITableViewScrollPositionTop];
}
我使用这种技术来选择两个 UITableViewCells
,所以用户知道哪个单元格在表视图下面的 UIDatePicker
它会生效。当您创建新活动并设置日期时,Apple在日历应用中使用此技术。
I'm using this technique to select one of two UITableViewCells
so the users knows which cell a UIDatePicker
below the table view it will effect. This technique is used by Apple in the calendar app when you create a new event and set the dates.
这篇关于如何在默认情况下选择UITableViewCell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文