【发布时间】:2011-03-03 14:42:49
【问题描述】:
我制作了一个 UIViewController,它以编程方式生成一个 UIScrollView。一切都很好,但是当我旋转设备时,UIScollView 应该调整大小,使其占据我的视图的完整宽度。
有没有办法在不重建完整 UIScrollView 的情况下做到这一点?
非常感谢! 塞巴斯蒂安
这在我的 viewDidLoad 中被调用:
-(void)buildmyScroller {
myScroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 800, 768, 100)];
//...adding some subviews to myScroller
thumbScroller.contentSize = CGSizeMake(3000, 100);
[[self view] addSubview:myScroller];
}
然后我尝试用这个来调整myScroller的大小,当我使用setFrame时,我说myScroller不会响应它......:
-(void)changemyScroller {
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
[thumbScroller setFrame:CGRectMake(0, 805, 768, 150)];
}
else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
thumbScroller.frame = CGRectMake(0, 805, 768, 150);
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
thumbScroller.frame = CGRectMake(0, 549, 1024, 150);
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
thumbScroller.frame = CGRectMake(0, 549, 1024, 150);
}
}
并在 didAnimateFirstHalf 中调用了该方法...因为我不知道在哪里调用它。
再次感谢!
【问题讨论】:
标签: iphone uiscrollview autoresize