Use*_*321 4 iphone self uialertview uiapplicationdelegate ios
我在MyapplicationAppDelegate.m文件中用2个按钮"取消"和"确定"调用UIAlert,调用警报,但点击"取消"或"确定"按钮
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
Run Code Online (Sandbox Code Playgroud)
方法未被调用.
我在MyapplicationAppDelegate.h文件中添加了UIAlertViewDelegate,如下所示
#import UIKit/UIKit.h
@interface MyapplicationAppDelegate: NSObject UIApplicationDelegate,UIAlertViewDelegate
{
..
}
Run Code Online (Sandbox Code Playgroud)
我想知道还需要什么.
在发布问题时我不确定它是否是您的拼写错误,但您应该在<..,..>中调用该委托
@interface MyapplicationAppDelegate: NSObject <UIApplicationDelegate,UIAlertViewDelegate> { .. }
Run Code Online (Sandbox Code Playgroud)
以下是UIAlertView的示例代码
UIAlertView *myAlertView = [[UIAlertView alloc]initWithTitle:@""message:@"Your message goes here" delegate:self cancelButtonTitle:@"OK"otherButtonTitles:nil];
[myAlertView show];
[myAlertView release];
Run Code Online (Sandbox Code Playgroud)
我不确定myAlertView.delgate = self是正确的方法,但我用initWithTitle设置委托