I want to have an UIImageView
in an UIScrollView
. But I it doesn't show any picture when I load it. My code looks like this in my viewController
in the function viewDidLoad
:
UIImage *image = [UIImage imageNamed:@"plan.gif"];
imageView = [[UI开发者_运维技巧ImageView alloc] initWithImage:image];
scrollView = [[UIScrollView alloc] init];
[scrollView addSubview:imageView];
scrollView.contentSize = image.size;
[self updateUI];
In my didFinishLaunchingWithOptions:
TestAppViewController *tavc = [[TestAppViewController alloc] init];
[self.window addSubview:tavc.view];
1) Check that your image name @"plan.gif"
is correct. Double-check.
2) Init your UIImageView
with a frame and add the image later.
imageView = [[UIImageView alloc] initWithFrame:
CGRectMake(0,0,scrollView.frame.size.width, scrollView.frame.size.height)];
// or choose another size
imageView.image = [UIImage imageNamed:@"plan.gif"];
Make sure that you have added the image to the project. Also, make sure that the file name is exactly the same (cAsE sensitive & correct extension).
精彩评论