【发布时间】:2014-03-20 10:56:02
【问题描述】:
我正在以编程方式添加一个滚动,但由于某种原因它没有从一开始就开始。
self.backgroundColor = [UIColor redColor];
self.scrollView = [[UIScrollView alloc]initWithFrame:self.frame];
self.scrollView.backgroundColor = [UIColor greenColor];
[self addSubview:self.scrollView];
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width, self.scrollView.frame.size.height);
这里有一些日志:
NSLog(@"contentOffset - %@",NSStringFromCGPoint(self.scrollView.contentOffset));
NSLog(@"contentSize - %@",NSStringFromCGSize(self.scrollView.contentSize));
NSLog(@"contentInset - %@",NSStringFromUIEdgeInsets(self.scrollView.contentInset));
NSLog(@"frame - %@",NSStringFromCGRect(self.scrollView.frame));
2014-03-20 12:53:56.356 contentOffset - {0, 0}
2014-03-20 12:53:56.357 contentSize - {320, 423}
2014-03-20 12:53:56.357 contentInset - {0, 0, 0, 0}
2014-03-20 12:53:56.358 frame - {{0, 156}, {320, 423}}
2014-03-20 12:53:56.360 contentOffset - {0, 0}
2014-03-20 12:53:56.360 contentSize - {320, 423}
2014-03-20 12:53:56.361 contentInset - {0, 0, 0, 0}
2014-03-20 12:53:56.361 frame - {{0, 156}, {320, 423}}
【问题讨论】:
-
什么是 NSLog(@"%@", NSStringFromCGRect(self.frame)) ?
-
而不是 self.frame 尝试 self.bounds
标签: ios objective-c cocoa-touch uiview uiscrollview