【发布时间】:2013-03-19 10:21:22
【问题描述】:
我有一个包含 6 个单元格的菜单第一个包含 UIViewController 第二个包含 UITableView
当我单击第一个单元格时,会出现一个新页面,其中包含一个按钮 当我单击此按钮时,我想访问菜单中的第二个单元格,其中包含一个 tableView
【问题讨论】:
-
我不明白你的要求..请用相关信息编辑你的问题,你想要实现什么等
我有一个包含 6 个单元格的菜单第一个包含 UIViewController 第二个包含 UITableView
当我单击第一个单元格时,会出现一个新页面,其中包含一个按钮 当我单击此按钮时,我想访问菜单中的第二个单元格,其中包含一个 tableView
【问题讨论】:
// 使用此代码刷新或删除或插入 TableviewCell
// reloading cell
NSIndexPath *tmpIndexpath=[NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:tmpIndexpath, nil] withRowAnimation:UITableViewRowAnimationTop];
// inserting cell
NSIndexPath *tmpIndexpath=[NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObjects:tmpIndexpath, nil] withRowAnimation:UITableViewRowAnimationTop];
// deleting cell
NSIndexPath *tmpIndexpath=[NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:tmpIndexpath, nil] withRowAnimation:UITableViewRowAnimationBottom];
【讨论】:
据我所知,您想在点击时从表格视图移动到其他视图的问题。所以,您必须使用与此类似的代码..
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
Detail *img1=[[Detail alloc]initWithNibName:@"Detail" bundle:Nil];
img1.labelString = [titleArray objectAtIndex:indexPath.row];
[self presentViewController:img1 animated:YES completion:nil];
}
【讨论】:
在UIButton Tapped Method 中写下以下 coed。
-(void) ButtonTapped:(UIButton *) sender
{
NSIndexPath *indexpathNew = [self.tblView indexPathForCell:(UITableViewCell *)[sender superview]];
NSLog(@"%@",indexpathNew.row);
}
indexpathNew 是单元格选定按钮的返回indextPath。
试试我的代码,我可能对你有帮助。
【讨论】: