vwa*_*arg 1 iphone objective-c bounds
当我尝试获取主屏幕的边界时[[UIScreen mainScreen] bounds],它返回null.我也尝试过[[UIScreen applicationFrame] bounds],仍然返回null.
奇怪的是; 如果我这样做NSLog(@"%@", [UIScreen mainScreen]);打印出正确的界限,虽然我不知道如何解析它,如果它甚至可能.
这是相关的代码:
-(void)loadView {
[super loadView];
CGRect pagingFrame = [[UIScreen mainScreen] bounds];
NSLog(@"%@", [[UIScreen mainScreen] bounds]); //prints null for me
NSLog(@"Width of original frame = %d", pagingFrame.size.width); //prints out 0
pagingFrame.origin.x -= pagingXOrigin;
pagingFrame.size.width += pagingWidthAdd;
NSLog(@"Width of adjusted frame = %d", pagingFrame.size.width); //still prints out 0
pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingFrame];
pagingScrollView.pagingEnabled = YES;
pagingScrollView.backgroundColor = [UIColor blackColor];
pagingScrollView.contentSize = CGSizeMake(pagingFrame.size.width * [self imageCount], pagingFrame.size.height);
self.view = pagingScrollView;
//Initialize sets
recycled = [[NSMutableSet alloc] init];
visible = [[NSMutableSet alloc] init];
[self tilePages];
}
Run Code Online (Sandbox Code Playgroud)
pagingScrollView 在头文件中声明,循环和可见.
我正在使用Xcode 3和iOS SDK 4.1.
我确信这有一个非常简单的解决方案,但是我仍然是Objective-C的新手,因此我无法解决它.
谢谢
Ben*_*ran 17
该NSStringFromCGRect方法使得快速记录CGRect变得更加容易.有关详细信息,请参阅Apple的文档,但这是一段代码:
CGRect screenBounds = [[UIScreen mainScreen] bounds];
NSLog(@"%@", NSStringFromCGRect(screenBounds));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6636 次 |
| 最近记录: |