开发者

Assigning Delegates to ViewController Classes

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)imagePickerControl开发者_StackOverflow社区ler:(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.


You can't assign a UIImageView to a UIImage. This might work better:

self.myImageView.image = img;


Are you actually allocating memory for 'myImageView'? It isn't shown. That's not automatic, myImageView = [[UIImageView alloc] init]; would be needed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜