views:

73

answers:

1

I'm developing iPad app using SplitView. And I put UIScrollView in DetailView by using Interface Builder. Then I add IBOutlet UIScrollView scrollView; in detailViewController.h that was automatically created by Xcode. And connected this scrollView to UIScrollView in DetailView.xib .

And I added below code to DetailViewController.m .

- (void)viewDidLoad {  
    [super viewDidLoad];  
    UIImageView *tempView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test.jpg"]];  
    self.imageView = tempView;  
    [tempView release];  
    scrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);  
    scrollView.maximumZoomScale = 4.0;  
    scrollView.minimumZoomScale = 0.75;  
    scrollView.clipsToBounds = YES;  
    scrollView.delegate = self;  
    [scrollView addSubView:imageView];
    [imageView release];
}

I think by add this code, scrollable image is shown in detailView. But nothings appear.

Please teach me how to display UIScrollView in detailView.

A: 

Try setting the frame property, like this:

tempView.frame = CGRectMake(0, 0, 100, 100); //x, y, width, height

Also, why are you first creating a tempView, then point self.imageView to it, and then release them both in the end? Wouldn't it be more readable and maintainable to just skip the self.imageView and just use tempView?

Rengers