当我仅为iPad设置时,标签栏图像没有调整大小,但如果我为所有设备设置它,则工作正常。
当iPhone / iTouch没有标签栏图像时的目标。当它的iPad显示标签栏图像。
将其设置为所有设备时的工作代码:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Emergency Management", @"Emergency Management");
self.tabBarItem.image = [UIImage imageNamed:@"swoosh"];
}
return self;
}
仅在设置为iPad时代码无效:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Emergency Management", @"Emergency Management");
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.tabBarItem.image = [UIImage imageNamed:@"swoosh"];
}
}
return self;
}
看起来一切都搞砸了:
正如你所看到的那样,使用第一个代码时前4个是正常的,但是当你为iPad设置它时,它们都搞砸了。