English 中文(简体)
UITextfields在显示UIImagePickerController之后的空白
原标题:UITextfields blank after showing UIImagePickerController

I have a form with two UITextFields and a button. The user enters values into the two fields and then clicks the button. This displays the UIImagePickerController so he/she can take a picture. After clicking the "Use" button on the picture preview, the UIImagePickerController is dismissed, but any text that had been entered in the two UITextFields is gone. This only happens on the IPhone (not the IPad) and only happens when the user uses the camera as opposed to choosing a picture from the camera roll. Here is the code.

-(IBAction)btnTakePic {
    if([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil];
    imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    imagePicker.allowsEditing = NO;
    [self presentModalViewController: imagePicker animated:YES];
    [imagePicker release];
}
else if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
    imagePicker.allowsEditing = NO;
    [self presentModalViewController:imagePicker animated:YES];
    [imagePicker release];
}
}

I have stepped through the debugger and upon entering the picker DidFinishPickingWithMediaInfo, the text fields are already blank, so the problem doesn t appear to be occurring in there. The IPad is running 4.3.3, the IPhone is 4.2.1, and the app is being developed in XCode 4 with 4.3 as the base sdk and 4.2 as the deployment target. Any help is appreciated.

最佳回答

I would suspect you are getting a memory warning (common when using the camera) and the view is unloading, when the view reloads (after returning from the image picker) the view is in its default state, boxes empty.

如果你确实将案文领域的财产设定为预期价值,那么你需要储存这些箱子的值(在变量中)。

检查青少年,你很可能 1级(或2级)

问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签