我有一个带有多个分段控件的 iPad 应用程序,包括一个带有两个控件的视图。
在这种情况下,一切都显示在 sim 中,包括正常和视网膜。但是,在设备中,只有一个显示。
以下是设备上未显示的代码。我已经检查过,构成控件的所有图像都复制到捆绑资源中。我试过移除、清洁等。没有乐趣。我一定错过了一些东西(希望很简单)..
UISegmentedControl *controls = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
[UIImage imageNamed:@"4.png"],
[UIImage imageNamed:@"5.png"],
[UIImage imageNamed:@"6.png"],
[UIImage imageNamed:@"7.png"],
nil]];
CGRect frame = CGRectMake(35, 70, 700, 35);
controls.frame = frame;
}
[controls addTarget:self action:@selector(drawSegmentAction:) forControlEvents:UIControlEventValueChanged];
controls.segmentedControlStyle = UISegmentedControlStyleBar;
controls.momentary = YES;
controls.tintColor = [UIColor grayColor];
[self.view addSubview:controls];
}
作为参考,同一视图中的此代码确实有效:
作为参考,此控制代码确实有效:
-(void) buildColorBar {
//NSLog(@"%s", __FUNCTION__);
UISegmentedControl *colorControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects: [UIImage imageNamed:@"White.png"],
[UIImage imageNamed:@"Red.png"],
[UIImage imageNamed:@"Yellow.png"],
[UIImage imageNamed:@"Green.png"],
[UIImage imageNamed:@"Blue.png"],
[UIImage imageNamed:@"Purple.png"],
[UIImage imageNamed:@"Black.png"],
nil]];
NSLog(@"Portrait");
CGRect frame = CGRectMake(35, 950, 700, 35);
colorControl.frame = frame;
// When the user chooses a color, the method changeBrushColor: is called.
[colorControl addTarget:self action:@selector(changeBrushColor:) forControlEvents:UIControlEventValueChanged];
colorControl.segmentedControlStyle = UISegmentedControlStyleBar;
// Make sure the color of the color complements the black background
colorControl.tintColor = [UIColor grayColor];
// Add the control to the window
[self.view addSubview:colorControl];
}
是否有禁止在一个视图中使用两个分段控件的规则?