我已經實現了每次返回0的代碼。我試圖從一個可變數組中刪除一個字符串,並在按下按鈕後選中該行的值。如何從表格視圖中正確獲取行值?
相關代碼:
- (IBAction)remove:(id)sender {
NSIndexPath *selectedIndexPath = [_tableView2 indexPathForSelectedRow];
[names removeObject:[NSString stringWithFormat:@"%i",selectedIndexPath.row]];
testLabel.text=[NSString stringWithFormat:@"%i",selectedIndexPath.row];
[_tableView2 reloadData];
}
測試標籤顯示0每次按下按鈕時,無論在哪裏的tableview被選擇。
讓我知道是否有其他相關的代碼(如tableView),你希望我發佈。
請看我的更新版本。 – LuisCien