2011-08-04 19 views
0

我有以下問題:的UIViewController與文本框和的tableView

我有一個UIViewController,它包含一個文本框和一個實現代碼如下。我從另一個視圖推動視圖,這樣我就得到了一個導航欄。我啓用了編輯按鈕,導航也可以正常工作。 我的問題是: - 編輯按鈕不起作用。我正在通過這裏查看,但我無法修復它 - 當我輸入數據到文本框時,tableview獲取數據,重新加載正在工作,但它不顯示任何動畫,也沒有添加行。 ..

-(BOOL)textFieldShouldReturn:(UITextField *)textField{ 
[controller insertCostumer:textField.text]; 

[textField resignFirstResponder]; 
[tabViewitem reloadData]; 

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:controller.sizeOfNavi+1 inSection:1]; 
NSMutableArray *arr = [[NSMutableArray alloc]init]; 
[arr addObject:indexPath]; 

[tabViewitem insertRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationTop]; 
return YES; 

}

這是我textfieldshouldreturn方法,我也嘗試了textfieldshouldendediting和textfielddidendediting等:-) 希望有人有任何線索如何做到這一點。

+0

您是否嘗試過先插入一行然後重新載入表格? – Vanya

+0

現在會做一個解決方法......設置一個標誌並以不同的方式編輯整個事物......不知道該怎麼做。 無論如何,如果有人發現了什麼,請讓我知道。 – markus

+0

@Vanya,是試過了太:-) – markus

回答

1

我沒有直接的解決方案,但我想我找到了一個有用的鏈接給你: http://www.iphonedevsdk.com/forum/iphone-sdk-development/11315-textfieldshouldreturn-not-called-probrem.html

這個人有一些問題,同時調用「textFieldShouldReturn」的方法。

+0

感謝,會研究 – markus

+0

嗯,該textfieldshouldreturn是beeing叫,但動畫中: 「\t [tabViewitem insertRowsAtIndexPaths:ARR withRowAnimation:UITableViewRowAnimationTop]; 」 不顯示。我沒有看到數據被添加到tableview中。只有當我切換到不同的視圖和回... – markus

+0

我看到你調用'insertRowsAtIndexPaths'到'tabViewitem'我看不到'tabViewitem'變量初始化,但在這裏幾個檢查:'tabViewitem '變量'IBOutlet UITableView'並且鏈接正確。 - 嘗試覆蓋'canEditRowAtIndexPath'並返回YES。 – Justin