0
我有一个iPad应用程序与几个分段控件,包括一个视图与两个控件。xcode:分段控制出现在SIM卡上,而不是在设备上
在该视图中,所有内容都显示在sim,normal和retina中。但是,在该设备中,只有一个显示。
下面是没有在设备上显示的代码..我已经检查并组成控件的所有图像被复制到束资源中。我试过去除,清洁等没有喜悦。我必须失去了一些东西(希望简单)..
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];
}
在一个视图中是否有使用两个分段控件的规则?
明显的问题...你把一个NSLog,并确保代码正在运行?如何使用一些随机背景颜色来制作UIView,看看它是创建控件的问题,还是更基本的布局/添加子视图问题? – DBD 2012-04-24 19:56:56
是的,代码已记录并正在运行。我可以看到按钮也起作用(在SIM上)。奇怪的 ... – 2012-04-24 20:41:04