加载视图时未显示相机。相反,它显示了我设计的视图。在按钮操作中给出代码时,代码运行良好。 任何人都可以帮忙吗?代码如下
- (void)viewDidLoad {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
scroll_under.contentSize=CGSizeMake(1000,50);
if(scroll_under.contentOffset.x==0)
{
leftArrow.hidden=TRUE;
}
if(scroll_under.contentOffset.x==429)
{
rightArrow.hidden=TRUE;
}
if(scroll_under.contentOffset.x>0 && scroll_under.contentOffset.x<429)
{
leftArrow.hidden=FALSE;
rightArrow.hidden=FALSE;
}
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
resultImage.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
答案 0 :(得分:1)
要使其正常工作,只需将代码移至:
- (void)viewDidAppear:(BOOL)animated
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self presentModalViewController:picker animated:YES];
}