0
我有一個UIPickerView,它能正常工作,現在我想在它上面添加一個按鈕,以便我可以解除它。UIPickerView上方的UIButton
,這裏是我的代碼,我開始一個UIPickerView以及其解僱按鈕:
- (UIPickerView *)creatPickerView {
UIPickerView *tempPickerView = [[[UIPickerView alloc]
initWithFrame:CGRectMake(kPickerViewX, kPickerViewY, kPickerViewWidth, kPickerViewHeight)] autorelease];
tempPickerView.showsSelectionIndicator = YES;
tempPickerView.delegate = self;
tempPickerView.dataSource = self;
UIButton *pickerButton = [[UIButton alloc] initWithFrame:CGRectMake(270, -32, 50, 32)];
[pickerButton setBackgroundImage:[UIImage imageNamed:@"hidePicker.png"]
forState:UIControlStateNormal];
[pickerButton addTarget:self action:@selector(hidePicker)
forControlEvents:UIControlEventTouchUpInside];
[tempPickerView addSubview:pickerButton];
[pickerButton release];
[self.view addSubview:tempPickerView];
return tempPickerView;
}
和它運作良好,在我的iPhone 4.3模擬器,就像這樣:
顯然在pickerView的右上方有一個按鈕,
問題是,當我在我的設備中運行應用程序 - 一個5.0.1 iPhone4和一個4.2.1 iTouch,該按鈕被遺漏,因爲它從未被添加到pickerView。
任何人都可以幫助我嗎?
非常感謝和很多!