开发者

Assigning Delegates to ViewController Classes

开发者 https://www.devze.com 2023-04-07 22:49 出处:网络
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, didFinishPickingImag

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

精彩评论

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