将委托分配给 ViewController 类
遵循这个模式。
// foo.m
Bar* bar = [[Bar alloc] init];
[baz setDelegate:bar];
[bar release];
我可以在 Bar 类中调用 UIImagePicker 委托。具体来说,didFinishPickingImage。但是,我无法设置 IBOutlet UIImageView myImageView。喜欢。
// bar.m
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
self.myImageView.image = img;
当我调试 UIImageView 时,我认为它是 nil,因为传递给 didFinishPickingImage 的 UIImage 参数也是空白的。
我的问题是,为什么?我假设我按照此示例正确设置了委托。
Following this pattern.
// foo.m
Bar* bar = [[Bar alloc] init];
[baz setDelegate:bar];
[bar release];
I'm able to call UIImagePicker Delegates in the Bar Class. Specifically, didFinishPickingImage. However, I'm not able to set my the IBOutlet UIImageView myImageView. like.
// bar.m
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
self.myImageView.image = img;
When I debug UIImageView, it's nil I think because the UIImage param passed to didFinishPickingImage is also blank.
My question is, why? I am assuming I set my delegate correctly as per this example.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能将 UIImageView 分配给 UIImage。这可能效果更好:
You can't assign a UIImageView to a UIImage. This might work better:
您实际上是为“myImageView”分配内存吗?它没有显示。这不是自动的,需要
myImageView = [[UIImageView alloc] init];
Are you actually allocating memory for 'myImageView'? It isn't shown. That's not automatic,
myImageView = [[UIImageView alloc] init];
would be needed