我做了一个UIScrollView
宽度随着触摸而变化的。当当前视图控制器切换到下一个时,我想保存 UIScrollView 的宽度。当视图控制器再次显示时,UIScrollView
应该恢复 ' 的宽度。
//TouZiViewController is the current view controller
@implementation TouZiViewController
...
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"toTouZi2"])
{ //TouZi2ViewController is the destination view controller
TouZi2ViewController *viewController2=[segue destinationViewController];
//huatiaoRect is CGRect,fullHuaTiao is the outlet of UIScrollView
viewController2.huatiaoRect=self.fullHuaTiao.frame;
}
}
@end
@implementation TouZi2ViewController
...
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"toTouZi"])
{
TouZiViewController *viewController=[segue destinationViewController];
[viewController loadView];
viewController.fullHuaTiao.frame=self.huatiaoRect;
}
}
@end
问题是当我从第二个视图控制器回来时,UIScrollView
' 的位置比以前高得多。为什么是这样?
更新
现在我发现问题是由于自动调整大小。我在情节提要中更改了自动调整大小,然后效果很好。