gpt4 book ai didi

iphone - 向 UIDatePicker 添加值

转载 作者:行者123 更新时间:2023-11-28 18:43:46 25 4
gpt4 key购买 nike

我需要将项目添加到 UIDatePicker,而不是添加日期:

shot of UIDatePicker

我需要添加一个名字列表(例如,“James”)。我该怎么做?

最佳答案

只需使用 UIPickerView

 UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
myPickerView.delegate = self
myPickerView.showsSelectionIndicator = YES;
[self.view addSubview:myPickerView];

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return 1;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *string = [NSString stringWithString:@"Jack"];
return string;
}

编辑:1

- (NSInteger)selectedRowInComponent:(NSInteger)component
{
//Returns the index of the selected row in a given component.
NSLog(@"%d",component);
}

关于iphone - 向 UIDatePicker 添加值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7880008/

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