UITableViewCell Set最初选择 [英] UITableViewCell Set selected initially
本文介绍了UITableViewCell Set最初选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我的情况是在iPad应用中我的主控制器
有列表,详细信息控制器有详细信息,典型的 UISplitViewController
模式。
我想要实现的是,我的第一行应该是最初选择的,之后我想给用户选择。
我正在使用单元格的 setSelected
,并在 didSelectRowAtIndexPath
方法中删除这样的选择。
Hi there I have situation where in an iPad app my master controller
has list and details controller have its details , a typical UISplitViewController
pattern.
What I want to achieve is , my first row should be initially selected and later I want to give selection choice to user.
I am using cell's setSelected
and in didSelectRowAtIndexPath
method removing selection like this.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
NSIndexPath* path = [NSIndexPath indexPathForRow:0 inSection:0];
UITableViewCell* cell = [tableView cellForRowAtIndexPath:path];
[cell setSelected:NO];
}
初始单元格的
但是我的无单元格在
之后被选中请帮帮我。
for initial cell but my none cell is getting selected after that please help me out.
推荐答案
试试这个
NSIndexPath* selectedCellIndexPath= [NSIndexPath indexPathForRow:0 inSection:0];
[self tableView:tableViewList didSelectRowAtIndexPath:selectedCellIndexPath];
[tableViewList selectRowAtIndexPath:selectedCellIndexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
OR
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (/* should be selected */) {
[cell setSelected:YES animated:NO];
}
}
这篇关于UITableViewCell Set最初选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文