2013-12-22 36 views
0

我不確定如何爲通用應用程序設置不同的滾動條大小尺寸。滾動在通用應用程序中查看內容大小?

我在下面的代碼中實現了iPhone尺寸的實現文件,但不知道如何編寫iPad滾動條尺寸。

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

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

} 

謝謝!

回答

3

利用這一點,所以你可以設置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 IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 
#define IS_IPHONE5 (!IS_IPAD && ([[UIScreen mainScreen] bounds].size.height >= 568)) 

這種方式,您可以在源只需使用:

if (IS_PAD) { 

} else if (IS_IPHONE5) { 

} 
+0

太謝謝你了!我忘了問iphone5以及上述情況。 – user1470914

+0

再次感謝你這麼多塞博! – user1470914

+0

不客氣:-) – thorb65

相關問題