ios - Added UIScrollView and UIImageView in storyboard - the image is squished and does not scroll -
In Xcode 5.0.2 I have created a
UIScrollView
and an iPhone and iPad storyboard (here) in a UIImageView
:
Then I will type the following code in board.png
(Copyright Wikipedia Commons, Dennelson 83):
- (zero) viewDidoadload {[Super Viewedload]; UIImage * img = [UIImage imageNamed: @ "board"]; NSLog (@ "% s: IMG =% @ (% F x% F)", __PRETTY_FUNCTION__, IMG, IMG size.width, img.size.height); _imageView.image = img; _scrollView.contentSize = img.size; }
Although the result is selected and the image can not be scrolled:
- [View controller viewDidload]: IMG = & lt; UIImage: 0x10912d770 & gt; (1000.000000 x 961.500000)
Any advice please? I suspect that the image has been cut from the bottom because I run a 3.5-inch iPhone simulator? How to fix this too?
Update:
I am trying to add four 0-odds in the scroll view so that it can take the whole screen, but when I The simulator with the CMD-Arrow will rotate - resizing the scroll view (not here):
Update 2:
When I use the "code" UIImageView "View Mode in the Xcode Storyboard and Source Code "So I changed the" top left "the following:
- (minus) Drishydidlod {[super Wudidlod]; UIImage * img = [UIImage imageNamed: @ "board"]; _imageView.image = img; _imageView.frame = CGRectMake (0, 0, img.size.width, img.size.height); _scrollView.contentSize = img.size; }
Then I get the following result, which can not be scrolled:
and can not be rotated (not filling the screen):
Remember Keep in mind that the storyboard image is already shaped by the storyboard, and you can never load anything in your code after loading your image. Will not take shape. So, it is above my head, but try:
UIImage * image = [UIImage imageNamed: @ "board"]; _imageView.image = image; _imageView.bounds = CGRectMake (0, 0, image.size.width, image.size.height); - (zero) viewDidleWatchSubview {_scrollView.contentSize = _imageView.bounds.size; }