-3

在我的应用程序中,我有很多文本字段,最后还有拍照按钮。但是当我从选择照片返回时,插入的文本字段值显示为空白。

单击照片按钮时,我尝试将文本字段值存储到字符串中。当我从那里返回时,我将字符串值设置为 text fied 但它向我展示了糟糕的过度。

帮我!!

-(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);
}
4

2 回答 2

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);
}
于 2012-09-14T05:44:48.617 回答
0

试试这个:

if (clkph) {
     NSString* txtdate=[NSString stringWithFormat:@"%@",phdate];
     NSLog(@"%@",txtdate);
     NSString* txttime=[NSString stringWithFormat:@"%@",phtime];
     NSLog(@"%@",txttime);
 }
于 2012-09-14T05:41:34.480 回答