嵌入的ImageView滚动型与自动布局在iOS 6 [英] Embed ImageView in ScrollView with Auto Layout on iOS 6
问题描述
我想做出非常简单的元素与新的iOS自动布局6 SDK。
我有一个ImageView的和滚动型嵌入它。 (一切建立与界面生成器)。该PNG文件设置和ImageView的模式被设定为左上
I am trying to make very simple element with new iOS 6 SDK with auto layout. I have an ImageView and Embed it in ScrollView. (everything build with Interface Builder). The .png file is set and imageView mode is set to "Top Left".
实施
#import "ImaginariumViewController.h"
@interface ImaginariumViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end
@implementation ImaginariumViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.scrollView.contentSize = self.imageView.image.size;
self.imageView.frame =
CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);
}
@end
当我运行应用程序,图像不滚动。做自动布局都是一样的关闭(使用Struts和弹簧),我有工作滚动。
我想这个问题是制约因素。任何人可以帮助我,好吗?
When I run the app, the image is not scrolled. Doing all the same with auto layout turned off (with struts and springs), I have working scrolling. I guess the problem is with constraints. Could anybody help me, please?
推荐答案
我刚遇到我是更新教程同样的问题。我试图删除编程的限制,骂,以及敲我的头撞墙 - 没有运气
I just encountered the same issue in a tutorial that I was updating. I attempted programmatically deleting constraints, cursing, and banging my head against the wall - no luck.
大约5分钟前,不过,我试过的东西,有固定的我遇到的另外一个问题,并ただ! UIScrollView的再次合作!解决的办法是移动老code表示的UIScrollView contentSize属性设置成viewDidAppear的实现,而不是viewDidLoad中:
About 5 minutes ago, however, I tried something that had fixed another issue I encountered, and, ta da! UIScrollView is working again! The solution was to move the old code that sets the UIScrollView contentSize property into an implementation of viewDidAppear, rather than viewDidLoad:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.theScroller.contentSize=CGSizeMake(200.0,2000.0);
}
我希望这可以帮助别人遇到了一些已经出现了自动布局的烦恼。
I hope this helps someone else encountering some of the headaches that have appeared with Auto Layout.
这篇关于嵌入的ImageView滚动型与自动布局在iOS 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!