在我的 iPhone 应用程序中,我有一个NSObject
A 类和一个UIViewController
B 类。我想从 A 调用 B 类中的一个实例方法。我使用了以下代码。
Bclass *vc = [[Bclass alloc]init];
[vc hideAlert:NSString];
[vc release];
在 B 类中:
- (void)hideAlert:(NSString*)message{
UIAlertView *shareAlrt = [[UIAlertView alloc] initWithTitle:@""
message:message
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[shareAlrt show];
[shareAlrt release];
}
并调用该方法并显示一个 AlertView。单击确定按钮时,我想导航到 Cclass 类。
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
Cclass *vc = [[Cclass alloc]initWithNibName:@"Cclass" bundle:[NSBundle mainBundle]];
[self presentModalViewController:vc animated:NO];
[vc release];
}
}
但是当我点击确定按钮时,应用程序崩溃了。这里发生了什么事?我已经<UIAlertViewDelegate>
在 B class.h 文件中添加了,但仍然是同样的错误。请帮忙
我收到错误代码*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType alertView:clickedButtonAtIndex:]: unrecognized selector sent to instance 0x81baa80'