我的UITableView通过PopOverViewController打开,所以如何在app加载后自动加载其中一个单元格,
MainViewController上的单元格选择过程
- (void)setDetailItem:(id)newDetailItem {
if (detailItem != newDetailItem) {
[detailItem release];
detailItem = [newDetailItem retain];
//---update the view---
label.text = [detailItem description];
}
}
Run Code Online (Sandbox Code Playgroud)
和TableViewController中的单元格选择:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
myAppDelegate *appDelegate =
[[UIApplication sharedApplication] delegate];
appDelegate.viewController.detailItem = [list objectAtIndex:indexPath.row];
}
Run Code Online (Sandbox Code Playgroud)
我在TableViewController中使用此代码但不起作用!这意味着按下popOver按钮后代码只需突出显示单元格!
[myTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:0];
Run Code Online (Sandbox Code Playgroud)
我在上面不同的方法,如代码中使用viewDidAppear,viewWillAppear并且didSelectRowAtIndexPath和...
谢谢