Ios 将参数发送到AlertView
我有一个委托,它接收一条消息,删除一个作为参数的项。 我想显示确认AlertView,然后,如果用户按Yes,我想删除它 所以,我得到的是 被调用的委托方法:Ios 将参数发送到AlertView,ios,parameters,uialertview,Ios,Parameters,Uialertview,我有一个委托,它接收一条消息,删除一个作为参数的项。 我想显示确认AlertView,然后,如果用户按Yes,我想删除它 所以,我得到的是 被调用的委托方法: - (void) deleteRecording:aRecording(Recording*)aRecording { NSLog(@"Cancel recording extended view"); UIAlertView *alert = [[UIAlertView alloc]
- (void) deleteRecording:aRecording(Recording*)aRecording {
NSLog(@"Cancel recording extended view");
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: NSLocalizedString(@"Cancel recording",nil)
message: NSLocalizedString(@"Are you sure you want to cancel the recording?",nil)
delegate: self
cancelButtonTitle: NSLocalizedString(@"No",nil)
otherButtonTitles: NSLocalizedString(@"Yes",nil), nil];
[alert show];
[alert release];
}
以及检查按下哪个按钮的方法:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:
{
NSLog(@"Delete was cancelled by the user");
}
break;
case 1:
{
NSLog(@"Delete deleted by user");
}
}
}
所以,我的问题是,如何将aRecording参数从第一个方法发送到第二个方法
非常感谢
myAlertView.tag = YOUR_INT;
CustomAlertView *alert = [[CustomAlertView alloc]
initWithTitle: NSLocalizedString(@"Cancel recording",nil)
message: NSLocalizedString(@"Are you sure you want to cancel the recording?",nil)
delegate: self
cancelButtonTitle: NSLocalizedString(@"No",nil)
otherButtonTitles: NSLocalizedString(@"Yes",nil), nil];
[alert setObject:YOUR_OBJECT];
[alert show];
[alert release];
在代表中
- (void)alertView:(TDAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"%@", [alertView object]);
}
myAlertView.tag = YOUR_INT;
CustomAlertView *alert = [[CustomAlertView alloc]
initWithTitle: NSLocalizedString(@"Cancel recording",nil)
message: NSLocalizedString(@"Are you sure you want to cancel the recording?",nil)
delegate: self
cancelButtonTitle: NSLocalizedString(@"No",nil)
otherButtonTitles: NSLocalizedString(@"Yes",nil), nil];
[alert setObject:YOUR_OBJECT];
[alert show];
[alert release];
在代表中
- (void)alertView:(TDAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"%@", [alertView object]);
}
+1.总结得好。至于2)——你也可以将自定义对象与警报关联起来,但是我会认为它是黑客的…3)一个不应该子类UIActuvVIEW。根据:UIAlertView类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不能修改。@soemarkoridwan感谢您的提示。。我把它添加到答案中。。不知怎的,以前从来没有读过。好的总结。至于2)——你也可以将自定义对象与警报关联起来,但是我会认为它是黑客的…3)一个不应该子类UIActuvVIEW。根据:UIAlertView类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不能修改。@soemarkoridwan感谢您的提示。。我把它添加到答案中。。不知怎的,以前从未读过。。