我用這個代碼在uiactionsheet中顯示uipicker,但是當我點擊關閉按鈕時,我想從視圖中刪除操作表。所以刪除actionSheet表單視圖的代碼應該是什麼。如何解僱行動表
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[actionSheet addSubview:pickerView];
[pickerView release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[closeButton release];
[actionSheet showInView:self.view];//[UIApplication mainWindow]];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
return false;
}
我已經使用[actionsheet removeFromSuperview] ;但它不起作用。 – 2011-04-20 06:39:09
請參閱http://stackoverflow.com/questions/1551587/how-to-dismiss-uiactionsheet-automatically – 2011-04-20 06:46:26