请找到下面的代码,我试图以添加工具栏到uipicker,但它不工作UIToolbar
请让我知道
UIPickerView *pickerViewCountry = [[UIPickerView alloc] init];
pickerViewCountry.showsSelectionIndicator = YES;
pickerViewCountry.dataSource = self;
pickerViewCountry.delegate = self;
pickerViewCountry.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
[pickerViewCountry sizeToFit];
pickerViewCountry.frame = CGRectMake(0,210 , 320, 15);
[self.view addSubview:pickerViewCountry];
//[pickerViewCountry release];
UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(10,200, 320, 44);
toolbar.barStyle = UIBarStyleBlackTranslucent;
[pickerViewCountry addSubview:toolbar];
[toolbar release];
我想这样做的uipicker按钮,所以我想下面的 – user198725878 2011-12-24 05:50:53
你可以添加UIToolbar作为'self.view'的子视图,并且仍然使它作为picker的完成按钮,只需设置一个IBAction调用来链接到done按钮即可。 – johnluttig 2011-12-24 06:01:11
神秘解决。将接口项添加到子视图中时,项目的框架与其父框架相关。 – jcpennypincher 2012-09-13 21:12:25