gpt4 book ai didi

iPhone 相机不显示

转载 作者:行者123 更新时间:2023-11-29 13:37:41 24 4
gpt4 key购买 nike

我在操作表中使用 ios 相机时遇到了尴尬的问题:当用户触摸“图片按钮”时,操作表会显示两个选项(使用照片库中的照片或使用相机)。

无论我选择什么选项,都没有任何反应,但当我再次选择媒体类型时,它会起作用。

下面是我的代码:

 - (IBAction)selectMediaType: (id)sender {
[appDelegate hideTabBar];
UIActionSheet *action = [[UIActionSheet alloc]
initWithTitle: nil
delegate:self
cancelButtonTitle:@"Fechar"
destructiveButtonTitle: nil
otherButtonTitles:@"Galeria", @"Tirar Foto", nil];

[action showFromTabBar: appDelegate.tabController.tabBar];
}


- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
NSArray *mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];

imagePicker.delegate = self;
imagePicker.hidesBottomBarWhenPushed = YES;
imagePicker.mediaTypes = mediaTypes;
imagePicker.allowsEditing = NO;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[self presentModalViewController:imagePicker animated:YES];
imagePicker.hidesBottomBarWhenPushed = YES;
} else if (buttonIndex == 1) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
NSArray *mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];

imagePicker.delegate = self;
imagePicker.mediaTypes = mediaTypes;
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

[self presentModalViewController:imagePicker animated:YES];
} else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@""
message:@"Your device does not support this feature!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
[alert release];

}
} else {
[appDelegate showTabBar];
}
}



- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image;
NSURL *mediaURL;

mediaURL = (NSURL *) [info valueForKey:UIImagePickerControllerMediaURL];

if (mediaURL == nil) {
image = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalImage];
}

imageView.image = image;

[picker dismissModalViewControllerAnimated:YES];

[appDelegate showTabBar];
}

- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissModalViewControllerAnimated:YES];

[appDelegate showTabBar];
}

谁能帮我解决这个问题?

谢谢。

最佳答案

我明白了。

基本上这是一个内存泄漏问题:我正在切换 View ,在 super View 中添加 subview (而不是在当前 View 中),但我没有从 super View 中删除旧的,所以我遇到了内存泄漏;)

关于iPhone 相机不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10088740/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com