0
ユーザーが持っている電話機のサイズを検出し、スクロールビューの長さを適切なサイズに設定しようとしました。たとえば、ユーザーがiPhoneに加えて、スクロールの長さを使用している場合は、ユーザーがiPhone 5ユーザーが持っている電話機のサイズを検出し、スクロールビューの長さを適切なサイズに設定しようとしました
- (void)scrollViewDidScroll:(UIScrollView *)sender {
if (!pageControlBeingUsed) {
// Switch the indicator when more than 50% of the previous/next page is visible
CGFloat pageWidth = self.scroll2.frame.size.width;
int page = floor((self.scroll2.contentOffset.x - pageWidth/3)/pageWidth) + 1;
self.pageControl.currentPage = page;
}
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
if ([[UIScreen mainScreen] scale] == 2.0) {
if([UIScreen mainScreen].bounds.size.height == 667.0){
self.scroll2.contentSize = CGSizeMake(300, 100);
// iPhone retina-4.7 inch(iPhone 6)
}
else if([UIScreen mainScreen].bounds.size.height == 568.0){
self.scroll2.contentSize = CGSizeMake(300, 5500);
// iPhone retina-4 inch(iPhone 5 or 5s)
}
else{
// iPhone retina-5 inch inch(iPhone Plus)
}
}
}
[iOSでスクリーンの幅と高さを取得する方法は?](https://stackoverflow.com/questions/5677716/how-to-get画面の幅と高さを指定します) – the4kman