2011-10-17 26 views
0

我有一個表格視圖,其中我有3 rows.first行是選擇時鐘應該是在模擬還是數字時尚.2.2行有一個切換開關打開時顯示天氣。第3行顯示時間格式,即用戶是否想要以24小時格式或12格式選擇時間。第2行已完成。但我對如何處理第一行默認情況下,在第一行的數字應該顯示,當我點擊單元格文本應該從數字改爲模擬。請幫助我解決這個問題。謝謝如何通過點擊iphone中的detailtextlabel切換到另一個視圖

回答

0
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
      UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 
if(indexPath.row == 0){ 
if([cell.textLabel.text isEqualToString:@"Analog"]){ 
      cell.textLabel.text = @"Digital"; 
} 

else{ 

cell.textLabel.text = @"Analog"; 
} 
} 

} //如果您正在使用任何其他標籤來顯示這些值,請用lbl.text替換cell.textLabel.text。

0

所以你想更新UITableView的第一個細胞detailTextLabel,用戶點擊它後,對吧?

TableView中的委託方法

好了,言歸正傳有指向同用戶點擊並修改它的detailTextLabel細胞....

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
      UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 
      cell.textLabel.text = @"New Text"; 

}

只需確保檢查哪個小區的用戶點擊更改文本之前,因爲你有3個小區... 要麼檢查單元行,或者小區現有文本

相關問題