Correct way to implement loadView?

I have a question regarding the implementation of loadView:

Now it looks like this for me:

- (void)loadView { image = [UIImage imageNamed:@"plan.gif"]; scrollView=[[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; imageView = [[UIImageView alloc] initWithFrame: CGRectMake(0, 0,scrollView.frame.size.width + 40, scrollView.frame.size.height)]; imageView.image = image; [imageView setContentMode:UIViewContentModeCenter]; scrollView.contentSize = image.size; scrollView.maximumZoomScale = 3.0; scrollView.bounces = NO; scrollView.delegate = self; // do any further configuration to the scroll view // add a view, or views, as a subview of the scroll view. [scrollView addSubview:imageView]; // release scrollView as self.view retains it self.view=scrollView; [scrollView release]; } 

I suggest that some of them should be in viewDidLoad :?

Thanks in advance.

+4
source share
1 answer

It seems wonderful to me.

viewDidLoad usually used as your hook after receiving the view received from IB. In this case, you essentially just do the IB work in the code (tweak the heirachy view and tweak it).

Therefore, in this case, I think that separation of logic may be redundant, unless the code becomes more readable.

0
source

All Articles