請找到下面的代碼,我試圖以添加工具欄到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