2013-05-03 73 views
2

的所有我需要做的是如何获取特定的部分编号及其在uitableview中的行号......主要是表中包含20个部分。如何在适合的视图中获取行号,它包含部分

在此先感谢

+1

为了得到一个有意义的答案,请阅读常见问题的说明http://stackoverflow.com/questions/how-to-ask和我个人最喜欢的:http://mattgemmell.com/2008/12/08/你有什么试用 – 2013-05-03 10:55:34

回答

0

尝试这样,

你在didSelectRowAtIndexPath方法方法得到的值。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSLog(%@"%d", indexPath.row); 
   NSLog(%@"%d", indexPath.section); 

} 

您取得particuler节中的行数,然后使用

[tableView numberOfRowsInSection:indexPath.section]; 

编辑: -

UITableViewCell* cell = (UITableViewCell*)button.superview; 

这里you'l获得所选单元格,并通过使用这种细胞可以更改标签的值。

用于获取indexpath值当点击按钮,可以使用下面这行代码,

NSIndexPath *indexPath = [yourtableviewname indexPathForCell:(UITableViewCell *)sender.superview]; 
    NSLog(@"%d",indexPath.row); 
+0

请看我编辑的问题一次 – Krishna1251 2013-05-03 14:53:36

+0

@ Krishna1251:如果这个答案可以帮助你,那么接受它来清理社区。 – Balu 2013-05-09 16:05:41

-1

实施

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
int row=indexPath.row; 
int section=indexPath.section 
} 
-1

当用户点击一行

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    //section: 
    NSInteger section = indexpath.section 

    //row: 
    NSinteger row= indexpath.row  
} 

被调用。

0

查找选定的索引路径:NSIndexPath *selectedRowIndexPath = [self.tableview indexPathForSelectedRow];,然后使用NSUInteger selectedRow = selectedRowIndexPath.row;获取选定的行,并使用NSUInteger selectedSection = selectedRowIndexPath.section;获取选定的部分。

+0

我得到0的每件事情....对于你的代码 – Krishna1251 2013-05-03 11:35:11

+0

请看我编辑的问题一次 – Krishna1251 2013-05-03 14:53:05

相关问题