gpt4 book ai didi

iphone - 如何将 UIImagePickerController 添加为 subview 而不是模态视图

转载 作者:太空狗 更新时间:2023-10-30 03:48:46 26 4
gpt4 key购买 nike

我在我的一个 View 上有一个段 Controller ,现在在段 Controller 的第 0 个索引上,我想通过添加为 subview 而不是 ModalViewController 添加 UIImagePickerController(用于向用户显示相机 View )。现在 View 已加载,但它不显示任何相机 View 。我可以通过 presentModalViewController 并传递其对象来显示相机 View 。

这是代码--

if(segmentedControl.selectedSegmentIndex==0)

{

UIImagePickerController *cameraView = [[UIImagePickerController alloc] init];

cameraView.sourceType = UIImagePickerControllerSourceTypeCamera;

cameraView.showsCameraControls = NO;

//[self presentModalViewController:cameraView animated:YES]; //Working

[self.view addSubview:cameraView.view]; // Not Working

}

最佳答案

[self.view addSubview:picker.view];
[picker viewWillAppear:YES]; // trickery to make it show
[picker viewDidAppear:YES];

作为副作用,您会在顶部看到一个白色条,因为 UIImagePickerController 不打算与它一起使用。

关于iphone - 如何将 UIImagePickerController 添加为 subview 而不是模态视图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3675717/

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