gpt4 book ai didi

iphone - iphone中隐藏uipickerview的问题

转载 作者:行者123 更新时间:2023-12-03 19:43:51 24 4
gpt4 key购买 nike

enter image description here

我想在 pickerView 顶部显示 UIPickerView 和 UIToolBar,并带有完成和取消按钮。附件是相同的屏幕截图。我在 View 的底部也有选项卡栏 Controller ,我想在底部栏上显示 pickerView这就是为什么我在actionsheet中使用uipickerView。现在我的问题是如何在UIActionSheet中添加的cancelButton单击时关闭pickerView?

以下是显示pickerView的函数:

-(IBAction)setMile:(id)sender
{
menu = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
// Add the picker
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,55,0,0)];
pickerView.delegate = self;
pickerView.showsSelectionIndicator = YES; // note this is default to NO

UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,320,44)];
pickerToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerToolbar sizeToFit];

NSMutableArray *barItems = [[NSMutableArray alloc] init];


UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(setMileCancel:)];
[barItems addObject:cancelBtn];
[cancelBtn release];
cancelBtn=nil;

UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
[flexSpace release];
flexSpace=nil;

UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(setMileDone:)];
[barItems addObject:doneBtn];
[doneBtn release];
doneBtn=nil;


[pickerToolbar setItems:barItems animated:YES];
[barItems release];
barItems=nil;

[menu addSubview:pickerToolbar];
[menu addSubview:pickerView];
[menu showInView:self.view];
//[menu showFromTabBar:[[self tabBarController] tabBar]]; this code is not working
[menu setBounds:CGRectMake(0,0,320, 545)];
[pickerView release];
[menu release];
pickerView=nil;
menu=nil;
}

我有以下取消按钮点击代码

-(IBAction)setMileCancel:(id)sender
{
//[menu removeFromSuperview];
[menu dismissWithClickedButtonIndex:0 animated:YES];
}

最佳答案

 //   menu=nil;
Please comment this line, then it will work

关于iphone - iphone中隐藏uipickerview的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13427560/

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