gpt4 book ai didi

iphone - UIImagePickerController,检查相机

转载 作者:可可西里 更新时间:2023-11-01 04:21:32 27 4
gpt4 key购买 nike

-(void)viewDidLoad
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.showsCameraControls = NO;
[self.view addSubview:imagePicker.view];
}
else
{
// UIAlertView…
}
}

-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:NO completion:NO];
}

我想在您没有相机时发出警报。iPhone 应用程序启动并在此代码中移动。但是,崩溃(这个错误 >

return UIApplicationMain(argc, argv, nil, NSStringFromClass([CameraAppDelegate class])); > 线程 1:信号 SIGABRT) 在模拟器中运行时。

这是为什么?

最佳答案

使用此代码并在 .h 文件中添加 UIImagePickerControllerDelegate 委托(delegate)

 if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])  
{
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
picker.wantsFullScreenLayout = YES;
[self presentModalViewController:picker animated:YES];
}
else
{
UIAlertView *altnot=[[UIAlertView alloc]initWithTitle:@"Camera Not Available" message:@"Camera Not Available" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
altnot.tag=103;
[altnot show];
[altnot release];

}

关于iphone - UIImagePickerController,检查相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13699256/

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