面对我职业生涯中的一些奇怪时刻。我在UIViewController中有一些uitextfield和一个uitextview ......在模拟器和iPhone 4 iOS v 4.3.5上一切正常。但在iPhone 4 iOS v 4.0.1中,有时我会刷新整个视图。这有时意味着我的uitextfields& uitextview从相机中挑选图像后丢失了文字.....
为了解决这个问题我的尝试就是当视图消失时我在一些数组中保存了值.....当视图确实出现时我向数组框显示了数组值.....它的模拟器工作正常。但这次我的应用程序被卡在iPhone 4 iOS v 4.0.1上。
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"title : %@",actionSheet.title);
if (![actionSheet.title isEqualToString:@"Success"] && ![actionSheet.title isEqualToString:@"Error"] && ![actionSheet.title isEqualToString:@"خطأ"]) {
if(buttonIndex == 1) {
if([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker= [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
} else {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsImageEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController: picker animated:YES];
[picker release];
}
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
float actualHeight = img.size.height;
float actualWidth = img.size.width;
float imgRatio = actualWidth/actualHeight;
float maxRatio = 320.0/480.0;
if(imgRatio!=maxRatio){
if(imgRatio < maxRatio){
imgRatio = 480.0 / actualHeight;
actualWidth = imgRatio * actualWidth;
actualHeight = 480.0;
}
else{
imgRatio = 320.0 / actualWidth;
actualHeight = imgRatio * actualHeight;
actualWidth = 320.0;
}
}
CGRect rect = CGRectMake(0.0, 0.0, actualWidth, actualHeight);
UIGraphicsBeginImageContext(rect.size);
[img drawInRect:rect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if(imageCount == 1){
self.firstImage = image;
self.previewImage1.image =firstImage;
}else if(imageCount == 2){
self.secondImage = image;
self.previewImage2.image =secondImage;
}else if(imageCount == 3){
self.thirdImage = image;
self.previewImage3.image =thirdImage;
}else if(imageCount == 4){
self.fourthImage = image;
self.previewImage4.image =fourthImage;
}
[myImageNames replaceObjectAtIndex:imageCount-1 withObject:@"Assigned"];
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
答案 0 :(得分:1)
解决..从设备删除应用程序。然后重新启动设备并再次安装构建.... 现在从相机中挑选图像时uitextfield刷新没问题。 冷静的家伙....: - )