可能重复:
multiple UIAlertView issue在一个视图中的几个UIAlertView中:如何创建不同的代表
I`am初学者iOS开发者。我面临以下问题:
在我的应用程序有一个viewController与2 UIAlertView`s。其中一个具有UIdatePicker,另一个具有UIPickerView。换句话说 - 它们不同,具有不同的组件和各种处理算法。
而且他们必须有不同的处理程序。但我不知道,如何在一个viewController上创建不同的处理程序,并使用“委托:自我”。
我这样做:
-(IBAction)alertDataPicker:(id)sender
{
selectPickerController *dataPicker=[[selectPickerController alloc] initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:@"Отмена" otherButtonTitles:@"Сохранить", nil];
NSError *err;
NSFetchRequest *fetch = [[NSFetchRequest alloc] initWithEntityName:@"Authors"];
dataPicker.data = [self.context executeFetchRequest:fetch error:&err];
[dataPicker show];
}
-(IBAction)alertDatePicker:(id)sender
{
datePickerALertControllerViewController *pickerAlertView = [[datePickerALertControllerViewController alloc] initWithTitle:@" " message:@" " delegate:self cancelButtonTitle:@"Отмена" otherButtonTitles:@"Сохранить", nil];
pickerAlertView.datePickerView.date=[self stringToDate:createDate.text];
[pickerAlertView show];
}
#pragma mark UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"qwe");
//NSLog(@"%@",alertView.datePickerView.date);
//createDate.text =[self dateToString:alertView.datePickerView.date];
//NSLog(@"date %@...%@",date,alertView.datePickerView.date);
}
但Xcode中说,UIAlertView中不`吨有prorepty “datePickerView” - (空)alertView:(UIAlertView中*)alertView clickedButtonAtIndex:(NSInteger的)buttonIndex 但是如果指定来自另一个类的对象的属性会出现类似的问题。
如何创建一个不同的处理程序到我的UIAlertView?或者可以确定哪个类的对象称为此方法,并根据它去不同的算法?
在此先感谢您的帮助和建议。
FYI:在UIAlertView中类拟用作-是,不支持子类。该类的视图层次结构是私有的,不能修改。](http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html) – 2012-03-26 11:38:24