gpt4 book ai didi

iphone - 如何在UIActionSheet中添加UIPickerView

转载 作者:行者123 更新时间:2023-12-03 18:51:13 25 4
gpt4 key购买 nike

我有任务输入评级(1 - 5)值,所以我找到了以下日期选择器代码,任何人都可以帮助我更改以下代码,以便添加 UIPickerView 以选择从 1 到 5 的评级

UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Ratings" 
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil];

UIDatePicker *pickerView = [[UIDatePicker alloc] init];
pickerView.datePickerMode = UIDatePickerModeDate;

[menu addSubview:pickerView];
[menu showInView:self.view];
[menu sendSubviewToBack:pickerView];
[menu setBounds:CGRectMake(0,0,320, 500)];

CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = -100;
pickerView.bounds = pickerRect;

[pickerView release];
[menu release];

如何操作,以便评级文本字段将自动输入 UIPIckerView 中选定的值

谢谢

最佳答案

actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self     cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;


picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,40, 320, 216)];
picker.showsSelectionIndicator=YES;
picker.dataSource = self;
picker.delegate = self;
picker.tag=SelectedDropDown;
[actionSheet addSubview:picker];

UIToolbar *tools=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 0,320,40)];
tools.barStyle=UIBarStyleBlackOpaque;
[actionSheet addSubview:tools];
[tools release];


UIBarButtonItem *doneButton=[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(btnActinDoneClicked)];
doneButton.imageInsets=UIEdgeInsetsMake(200, 6, 50, 25);
UIBarButtonItem *flexSpace= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

NSArray *array = [[NSArray alloc]initWithObjects:flexSpace,doneButton,nil];

[tools setItems:array];
[doneButton release];
[flexSpace release];

//picker title
UILabel *lblPickerTitle=[[UILabel alloc]initWithFrame:CGRectMake(60,8, 200, 25)];
lblPickerTitle.text=@"";
lblPickerTitle.backgroundColor=[UIColor clearColor];
lblPickerTitle.textColor=[UIColor whiteColor];
lblPickerTitle.textAlignment=NSTextAlignmentCenter;
lblPickerTitle.font=[UIFont boldSystemFontOfSize:15];
[tools addSubview:lblPickerTitle];


[actionSheet showFromRect:CGRectMake(0,480, 320,215) inView:self.view animated:YES];
[actionSheet setBounds:CGRectMake(0,0, 320, 411)];
[actionSheet release];

关于iphone - 如何在UIActionSheet中添加UIPickerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1958920/

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