[英]UIDatePicker is crashing without a reason
I have set UIDatePicker
in a cocos2d scene. 我在cocos2d场景中设置了
UIDatePicker
。 (hope its right) Its working great till the moment i have to pick a date, so i roll the picker and then the moment it stops, it crashes, and it doesnt even call the picker method. (希望它正确)直到我必须选择一个日期为止,它的工作都很好,所以我滚动选择器,然后在它停止的那一刻,它崩溃了,甚至没有调用选择器方法。
CGRect pickerFrame = CGRectMake(0,250,0,0);
UIDatePicker *myPicker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
[myPicker addTarget:self action:@selector(pickerChanged:)
forControlEvents:UIControlEventValueChanged];
//[self.view addSubview:myPicker];
[[[CCDirector sharedDirector] view] addSubview:myPicker];
[myPicker release];
- (void)pickerChanged:(id)sender
{
NSLog(@"value: %@",[sender date]);
}
btw did i add the picker to the cocos2d scene correctly? 顺便说一句,我是否已将选择器正确添加到cocos2d场景?
当选择器尝试调用您的方法时,它崩溃,但是目标( self
)可能已被释放,因此您应该获得EXC_BAD_ACCESS。
date is a property not a function ... sender is a DatePicker in this case. date是属性而不是函数。在这种情况下,发件人是DatePicker。 The code below should work!
下面的代码应该工作!
-(void)pickerChanged:(UIDatePicker*) datePicker{
NSLog(@"value: %@",datePicker.date);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.