如何在UiView中添加UIImagePickerController

发布于 2024-08-03 15:45:53 字数 61 浏览 2 评论 0原文

如何在TabBarApplication中的UiView中添加UIImagePickerController

How to add UIImagePickerController in UiView in TabBarApplication

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹎☆浅夏丿初晴 2024-08-10 15:45:53

如果您在选项卡中,此代码将进入您的视图的 ViewController 类,

当您需要一个选择器时创建一个选择器

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
// configure it how you want

添加选择器

[self presentViewController:picker animated:YES completion:nil];

您的视图控制器需要像这样声明

@interface YourViewController :  
   UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate>

并且您需要实现

- (void)imagePickerController:(UIImagePickerController *)picker 
    didFinishPickingMediaWithInfo:(NSDictionary *)info;
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;

(第一个应该从信息对象获取图像)

在每条消息中,完成后,删除选择器

[self dismissModalViewControllerAnimated:YES];

It doesn't matter if you are in a tab, this code goes into the ViewController class for your view

Create a picker when you want one

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
// configure it how you want

Add the picker

[self presentViewController:picker animated:YES completion:nil];

Your view controller needs to be declared like

@interface YourViewController :  
   UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate>

And you need to implement

- (void)imagePickerController:(UIImagePickerController *)picker 
    didFinishPickingMediaWithInfo:(NSDictionary *)info;
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;

(the first one should get the image from the info object)

In each of those messages, when done, remove the picker

[self dismissModalViewControllerAnimated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文