Xcode iPhone 时间选择器
我正在尝试为时间选择器设置 NSArray 类,我想知道是否可以使用 UIDatePicker
并仅导入 NSArray?
这就是我的代码:
- (IBAction)showActionTime:(id)sender {
NSString *title2 = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
UIActionSheet *actSheet = [[UIActionSheet alloc]
initWithTitle:[NSString stringWithFormat:@"%@", title2, NSLocalizedString(@"Please Select A Time", @"")]
delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"I've Made My Choice", nil];
[actSheet showInView:self.view];
UIPickerView *timePicker = [[[UIPickerView alloc] init] autorelease];
[timePicker setTag: time1];
//timePicker.
[actSheet addSubview:time1];
[timePicker addTarget:self
action:@selector(updateTimeLabel:)
forControlEvents:UIControlEventValueChanged];
[actSheet release];
}
- (void)updateTimeLabel:(UIActionSheet *) actSheet{
NSLog(@"Button Pressed");
NSArray *times = [[NSArray alloc] initWithObjects:@"8:00-11:00",@"2:00-5:00",nil];
UIPickerView *timePicker2 = (UIPickerView *) [actSheet viewWithTag:time1];
[times release];
//[formatter release];;
//UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Date" message:selectedDate delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
//label1.text = msg;
//[dateFormatter release];
//[alert show];
//[alert release];
//[msg release];
}
但它甚至不尝试加载 ActionSheet 开始。它只是立即崩溃。可能是什么问题?
*更新:
这是我的警告之一:
@implementation AppointmentController,警告是“不完整的实现”
,在这一行:
[timePicker addTarget:self action:@selector(updateTimeLabel)
我收到“程序收到信号:“SIGABRT”
I'm trying to set up an NSArray class for a time picker, I was wondering if I could use a UIDatePicker
and just import the NSArray?
This is what I have for code:
- (IBAction)showActionTime:(id)sender {
NSString *title2 = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
UIActionSheet *actSheet = [[UIActionSheet alloc]
initWithTitle:[NSString stringWithFormat:@"%@", title2, NSLocalizedString(@"Please Select A Time", @"")]
delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"I've Made My Choice", nil];
[actSheet showInView:self.view];
UIPickerView *timePicker = [[[UIPickerView alloc] init] autorelease];
[timePicker setTag: time1];
//timePicker.
[actSheet addSubview:time1];
[timePicker addTarget:self
action:@selector(updateTimeLabel:)
forControlEvents:UIControlEventValueChanged];
[actSheet release];
}
- (void)updateTimeLabel:(UIActionSheet *) actSheet{
NSLog(@"Button Pressed");
NSArray *times = [[NSArray alloc] initWithObjects:@"8:00-11:00",@"2:00-5:00",nil];
UIPickerView *timePicker2 = (UIPickerView *) [actSheet viewWithTag:time1];
[times release];
//[formatter release];;
//UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Date" message:selectedDate delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
//label1.text = msg;
//[dateFormatter release];
//[alert show];
//[alert release];
//[msg release];
}
But it doesn't even try to load the ActionSheet to begin with.It just crashes immediately. What could possibly be the problem?
*UPDATE:
Here is one of my warnings:
@implementation AppointmentController and the warning is "Incomplete Implementation"
and on this line:
[timePicker addTarget:self action:@selector(updateTimeLabel)
I'm getting "Program received signal: "SIGABRT"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Macfan9000,
time1 是什么?
为什么要将它添加为子视图?
我的猜测是你的意思是使用
[actSheet addSubview:timePicker];
Macfan9000,
What is time1?
And why are you adding it as a subview?
My guess is you mean to use
[actSheet addSubview:timePicker];