Ahm*_*ali 1 iphone objective-c uialertview code-design ios
我有这个警报:
没有互联网连接,请再试一次
我必须有许多代码块可以产生这个消息,我想把它放在UIAlertView一个我不会每次都创建它的类中,这可能吗?
用于ActionGeneric类的h文件
#import <Foundation/Foundation.h>
@interface ActionGeneric : NSObject {
}
+(void)showAlert;
@end
Run Code Online (Sandbox Code Playgroud)
m文件
#import "ActionGeneric.h"
@implementation ActionGeneric
+(void)showAlert{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"haveInternetConnection",@"")
message:@""
delegate:nil
cancelButtonTitle:NSLocalizedString(@"kOk",@"")
otherButtonTitles:nil];
[alert show];
[alert release];
}
@end
Run Code Online (Sandbox Code Playgroud)
然后你只需导入动作泛型并调用它
[ActionGeneric showAllert];
Run Code Online (Sandbox Code Playgroud)
你应该看看Learning Objective-C
| 归档时间: |
|
| 查看次数: |
1991 次 |
| 最近记录: |