fab*_*789 6 iphone objective-c ios ios7
我正在添加UIScrollView一个UIViewControllers view.由于某种原因,在将滚动视图添加到视图并显示之间,将contentOffset设置为{0, -64},64是状态栏的20加上导航栏的44点(我猜).下面是一些重现问题的代码和图像.
如何阻止iOS设置contentOffset?
- (void)viewDidLoad
{
[super viewDidLoad];
_scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 100, 100, 100)];
_scroll.backgroundColor = [UIColor greenColor];
_scroll.delegate = self;
UIView *red = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
red.backgroundColor = [UIColor redColor];
[_scroll addSubview:red];
[self.view addSubview:_scroll];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// outputs {0, -64}
NSLog(@"%@", NSStringFromCGPoint(_scroll.contentOffset));
}
Run Code Online (Sandbox Code Playgroud)

Dmi*_*nko 17
设置automaticallyAdjustsScrollViewInsets您的视图控制器上NO,否则它会在它的第一子视图调整插图这么恰巧是根视图UIScrollView类.
有关iOS 7 Transition Guide的更多信息.
| 归档时间: |
|
| 查看次数: |
1312 次 |
| 最近记录: |