views:

32

answers:

0

I have a XIB where I replaced the UIView with a UIScrollView. I made sure the outlet to File's Owner:view was linked to the new UIScrollView.

I'm trying to add a UIImageView to the UIScrollView programatically now. That's not a problem, but then I'd like to change the contentSize of self.view to match the new UIImageView. I've tried

(UIImageView *)self.view.contentSize = someUIImage.size;

which seems to cause Xcode to choke. So far the only way I've managed this is the following code:

UIImageView *tempView = [[UIImageView alloc] initWithImage:someUIImage];

UIScrollView *scrollView = (UIScrollView *)self.view;
scrollView.contentSize = someUIImage.size; 

[self.view addSubview:tempView];
[tempView release]; 

Is there any way to do it more efficiently?