2013-05-03 69 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

相關問題