我在我的应用程序 AppDelegate.m 文件中使用 2 个按钮“取消”和“确定”调用 UIAlert,但在点击“取消”或“确定”按钮时会调用警报
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
方法未被调用。
我在 MyapplicationAppDelegate.h 文件中添加了 UIAlertViewDelegate,如下所示
#import UIKit/UIKit.h
@interface MyapplicationAppDelegate: NSObject UIApplicationDelegate,UIAlertViewDelegate
{
..
}
我想知道还需要什么。
我不确定是否是您在发布问题时的拼写错误,但您应该在 <.. ..> 内致电代表
@interface MyapplicationAppDelegate: NSObject <UIApplicationDelegate,UIAlertViewDelegate> { .. }
这是 UIAlertView 的示例代码
UIAlertView *myAlertView = [[UIAlertView alloc]initWithTitle:@""message:@"Your message goes here" delegate:self cancelButtonTitle:@"OK"otherButtonTitles:nil];
[myAlertView show];
[myAlertView release];
我不确定 myAlertView.delegate = self 是正确的方法,但我确实使用 initWith Title 设置委托
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)