2012-04-26 75 views
0

我有這個代碼(XCode 4,使用故事板和ARC),它從數組(rArray)獲取數據並將其放置在它最初來自的文本字段中(我想編輯數據)。數組(rArray)中包含有效數據,但文本域中沒有任何數據。我究竟做錯了什麼?如何將數據導入文本框進行編輯?

SingletonListOfReadings *rShareInstance = [SingletonListOfReadings sharedInstance]; 
rArray *ra = [rShareInstance.listOfReadings objectAtIndex: indexPath.row]; // get an rArray object out of listOfReadings 

// place data back into textfields 
EnterDataViewController *edvc = [[EnterDataViewController alloc] init]; 
edvc.txtSTA1.text = ra.rSTA; 
edvc.txtBS.text = ra.rBS; 
edvc.txtFS.text = ra.rFS; 
edvc.txtDesc.text = ra.rDesc; 

[self.navigationController pushViewController:edvc animated:YES]; 

回答

0

我固定它...我把原來的代碼,並將其移動到視圖控制器(edvc)它處理的對象。然後我從需要數據的視圖控制器中調用它。

工作正常......我認爲問題在於接收文本字段的尋址。

謝謝你的幫助...我很感激。

1

的UI在VC文本元素,當您嘗試填充它目前尚未確定(會後,纔可以設置[self.navigationController pushViewController:edvc動畫:YES];(且僅當它得到viewDidLoad中) 。

簡單的方法去是txtSTA1,txtBS,txtFS等改變爲字符串(確保它們在edvc .h文件中),pupulate他們爲u現在要做的

所以,txtSTA1STR是在一個字符串.h文件的edvc 和txtSTA是xib中的UI文本元素(或編程方式)在edvc

EnterDataViewController *edvc = [[EnterDataViewController alloc] init]; 
edvc.txtSTA1STR = ra.rSTA; 
edvc.txtBSSTR= ra.rBS; 
edvc.txtFSSTR= ra.rFS; 
edvc.txtDescSTR= ra.rDesc; 

[self.navigationController pushViewController:edvc animated:YES]; 

和內部edvc

- (void)viewDidLoad 
{ 
    txtSTA1.text = txtSTA1STR; 
    //... etc 
} 
+0

我把它們設置爲屬性,並且ra.rxx的值仍然沒有進入strTxt字段。我在Storyboard和ARC中使用XCode4。 – SpokaneDude 2012-04-26 16:35:40

+0

確保它們被定義爲.H中的字符串,並帶有屬性,然後在M.中合成它們,然後在 - (void)viewDidAppear:(BOOL)動畫 do:textUIElement.text = stringName; – chewy 2012-04-27 07:51:47

相關問題