如何在nsobject类中调用UIAlertView



在nsobject类中调用ui警报视图时遇到问题。我想知道我是不是错过了什么。我得到

cannot find protocol definition "UIAlertViewDelegate"

提前谢谢。。

mynsobjectclass.h

@interface mynsobjectclass : NSObject <UIAlertViewDelegate>

@property (atomic, copy) NSString *serverURL
@end

mynsobjectclass.m

+(void)displayalert{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Hello there..." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil];
    [alert show];

}

UIAlertView现已弃用。UIAlertController应从iOS 8开始使用。如果您的目标是iOS 7或更低版本,UIAlertViewDelegate不能是NSObject的委托。它必须是UIView/UIWiewController的委托,因为它们需要显示警报

最新更新