UIToolBar を追加しようとしていますが、iPhone に表示されません。ただし、iPadには表示されます。私は何を間違っていますか?
UIToolbar *webToolBar = [[UIToolbar alloc]init];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
fixedSpace.width = 20.0;
[webToolBar setItems:[NSArray arrayWithObjects:backButton, forwardButton, flexibleSpace, refreshButton, fixedSpace, stopButton, nil]animated:NO];
webToolBar.frame = CGRectMake(0, [[UIScreen mainScreen]bounds].size.height - 44, [[UIScreen mainScreen]bounds].size.width, 44);
}
else
{
UIBarButtonItem *fixedSpaceiPad = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedSpaceiPad.width = 460.0;
fixedSpace.width = 50.0;
webToolBar.frame = CGRectMake(0, 660, 703, 44);
[webToolBar setItems:[NSArray arrayWithObjects:backButton, forwardButton, fixedSpaceiPad, refreshButton, fixedSpace, stopButton, nil]animated:NO];
}
webToolBar.delegate = self;
[webToolBar setBarStyle:UIBarStyleDefault];
webToolBar.tintColor = kfbBlue;
webToolBar.hidden = NO;
[webToolBar sizeToFit];
[self.view addSubview:webToolBar];
私もこんな風に並べてみました。この実装により、iPhone 4S、5、および 5S では正しい位置に表示されますが、6 または 6 Plus ではまったく表示されません。
CGSize result = [[UIScreen mainScreen] bounds].size;
NSInteger y = [[UIScreen mainScreen]bounds].size.height - 44;
NSInteger screenWidth = [[UIScreen mainScreen]bounds].size.width;
NSLog(@"Screen height = %f", [[UIScreen mainScreen]bounds].size.height);
NSLog(@"y = %ld and width = %ld", y, screenWidth);
fixedSpace.width = 20.0;
// webToolBar.frame = CGRectMake(0, y, screenWidth, 44);
[webToolBar setItems:[NSArray arrayWithObjects:backButton, forwardButton, flexibleSpace, refreshButton, fixedSpace, stopButton, nil]animated:NO];
if (result.height == 480)
{
webToolBar.frame = CGRectMake(0, 372, 320, 44);
}
else if (result.height == 568)
{
webToolBar.frame = CGRectMake(0, 460, 320, 44);
}
else if (result.height == 667) {
webToolBar.frame = CGRectMake(0, 623, 375, 44);
}
else if (result.height == 736) {
webToolBar.frame = CGRectMake(0, 692, 414, 44);
}