gpt4 book ai didi

objective-c - 对象在 presentModalViewController 之后返回 null

转载 作者:行者123 更新时间:2023-11-29 11:21:20 25 4
gpt4 key购买 nike

显示相机后,我的对象返回 null:

下面是我如何显示我的 UIImagePickerController(我之前初始化它):

[self presentModalViewController:pickerOne animated:NO];

我像这样在我的 scrollView 中添加一个对象,

UIImageView *overlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"black_overlay.png"]];
[overlay setFrame:CGRectMake(((columnCount-1)*100)+((columnCount-1)*5)+5 ,((rowCount-1)*100)+((rowCount-1)*5)+11, 100, 100)];
[overlay.layer setCornerRadius:8.0];
[overlay.layer setMasksToBounds:YES];
[overlay setTag:12];
[theImageViewer addSubview:overlay];

然后像这样访问它(在相机关闭后):

UIImageView *overlayImage = (UIImageView*)[theImageViewer viewWithTag:[[arrayOverlays objectAtIndex:[arrayIds indexOfObject:imageThumbnail]] intValue]];
NSLog(@"OverlayImage: %@",[arrayOverlays objectAtIndex:[arrayIds indexOfObject:imageThumbnail]]);

我得到:Real overlayImage, (null)

求助!谢谢。

最佳答案

  1. pickerOne 必须是当前 ViewController 中的一个属性。
  2. 您当前的 ViewController 必须符合 UIImagePickerControllerDelegate 的协议(protocol)。
  3. 在委托(delegate)的 imagePickerController:didFinishPickingMediaWithInfo: 实现中,您将获得图像对象并关闭 modalViewController

这应该可以解决问题。

编辑:刚刚找到了一个详细解释这个的教程:

http://iphone.zcentric.com/2008/08/28/using-a-uiimagepickercontroller/

注意:imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfoiOS 3.0

中已弃用

关于objective-c - 对象在 presentModalViewController 之后返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6985712/

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