gpt4 book ai didi

objective-c - 如何关闭操作表

转载 作者:太空狗 更新时间:2023-10-30 03:23:33 24 4
gpt4 key购买 nike

我使用此代码在 uiactionsheet 中显示 uipicker,但是当我单击关闭按钮时,我想从 View 中删除操作表。那么删除 actionSheet 表单 View 的代码应该是什么。

- (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,您可以使用 dismissWithClickedButtonIndex:animated:

关于objective-c - 如何关闭操作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5726408/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com