繁体   English   中英

滚动查看通用应用程序中的内容大小?

[英]Scroll View content size in Universal app?

我不确定如何为通用应用设置不同的滚动条尺寸。

到目前为止,我在iPhone尺寸的实现文件中有以下代码,但不确定如何为iPad滚动条尺寸进行编码。

- (void)viewDidLoad {
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    [super viewDidLoad];

[ScrollerInstructions setScrollEnabled:YES];
[ScrollerInstructions setContentSize:CGSizeMake(300, 2000)];

}

谢谢!

使用它,因此您可以根据设备的相关性来设置contenSize:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    // iPad contentSize
    [ScrollerInstructions setContentSize:CGSizeMake(600, 3000)];
} else if ([[UIScreen mainScreen] bounds].size.height >= 568) {
    // iPhone 5/5s contenSize
    [ScrollerInstructions setContentSize:CGSizeMake(300, 2500)];
} else {
    // old iPhone contenSize
    [ScrollerInstructions setContentSize:CGSizeMake(300, 2000)];
}

一个好的使用方法是,在.pch文件中将其设置为define,如下所示:

#define IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define IS_IPHONE5 (!IS_IPAD && ([[UIScreen mainScreen] bounds].size.height >= 568))

这样,您可以在源代码中简单地使用:

if (IS_PAD) {

} else if (IS_IPHONE5) {

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM