2012-09-14 58 views
-3

在我的應用程序中,我有很多文本字段&終於有拍照按鈕。但是,當我從選擇照片返回時,插入的文本字段值顯示爲空白。文本字段值不存儲在字符串中

我嘗試將文本字段值存儲到字符串中,當點擊圖片按鈕時。當我從那裏返回時,我將字符串值設置爲文本但是它顯示我不好。

幫幫我!

-(void)ViewWillAppear 
{ 
    if (clkph) { 
      txtdate.text=[NSString stringWithFormat:@"%@",phdate]; 
      NSLog(@"%@",txtdate.text); 
      txttime.text=[NSString stringWithFormat:@"%@",phtime]; 
      NSLog(@"%@",txttime.text); 
     } 
} 

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ 

    clkph=YES; 
    phdate=[NSString stringWithFormat:@"%@",txtdate]; 
    NSLog(@"%@",phdate); 
    phtime=[NSString stringWithFormat:@"%@",txttime]; 
    NSLog(@"%@",phtime); 
} 
+0

我們不能幫你,沒有任何一段代碼。請添加一些片段,以便我們檢查你在做什麼! – tamasgal

+0

檢查phdate和phtime是nsstring有值 –

+0

phdate&phtime by Nslog是:> 2012-09-14 11:11:36.503 CarAccidentApp [722:207] > – piyush

回答

2

做到這一點,因爲我認爲phdate和phtime爲的UITextField:

if (clkph) { 
     txtdate.text=[NSString stringWithFormat:@"%@",phdate]; 
      NSLog(@"%@",txtdate.text); 
      txttime.text=[NSString stringWithFormat:@"%@",phtime]; 
      NSLog(@"%@",txttime.text); 
    } 

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ 

    clkph=YES; 
    phdate=[NSString stringWithFormat:@"%@",txtdate.text]; 
    [phdate retain]; 
    NSLog(@"%@",phdate); 
    phtime=[NSString stringWithFormat:@"%@",txttime.text]; 
    [phtime retain]; 
    NSLog(@"%@",phtime); 
} 
+0

phdate是字符串,所以我們不能寫phdate.text – piyush

+0

是的,根據他的日誌(寫在評論中),'phdate'和'phtime'是'UITextField's。 Upvote – Novarg

+0

我嘗試你的代碼,但它不工作 – piyush

0

試試這個:

if (clkph) { 
    NSString* txtdate=[NSString stringWithFormat:@"%@",phdate]; 
    NSLog(@"%@",txtdate); 
    NSString* txttime=[NSString stringWithFormat:@"%@",phtime]; 
    NSLog(@"%@",txttime); 
} 
+0

亞,但是,當我嘗試將nsstring * txtdate設置爲文本字段值時,它具有文本字段的所有其他屬性如caLayer,框架, – piyush

相關問題