-2
有400 Alertview
对象加入,因为我们需要在旧的项目,所以在这里我想定义macro
在objective-c
UIAlertViewController
这是在iOS的8.0如何为UIAlertViewController定义宏?
介绍请帮我将其定义在不断的文件。
有400 Alertview
对象加入,因为我们需要在旧的项目,所以在这里我想定义macro
在objective-c
UIAlertViewController
这是在iOS的8.0如何为UIAlertViewController定义宏?
介绍请帮我将其定义在不断的文件。
只有对于Alertview
#define SHOW_ALERT(title,msg,del,cancel,other) \
do { \
UIAlertView *_alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:del cancelButtonTitle:cancel otherButtonTitles:other,nil]; \
[_alert show]; \
} while(0);
只有对于AlertViewController
#define SHOW_ALERT2(title,msg,ButtonTitle)\
do { \
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];\
UIAlertAction *actionOk = [UIAlertAction actionWithTitle:ButtonTitle\
style:UIAlertActionStyleDefault\
handler:nil]; \
[alertController addAction:actionOk];\
[self presentViewController:alertController animated:YES completion:nil];\
}while(0);
两种AlertView和AlertViewController
#define SHOW_ALERT3(title,msg,delegate,ButtonTitle) \
do { \
if ([UIAlertController class]) {\
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];\
UIAlertAction *actionOk = [UIAlertAction actionWithTitle:ButtonTitle\
style:UIAlertActionStyleDefault\
handler:nil]; \
[alertController addAction:actionOk];\
[self presentViewController:alertController animated:YES completion:nil];\
}\
else {\
UIAlertView *_alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:delegate cancelButtonTitle:ButtonTitle otherButtonTitles:nil]; \
[_alert show]; \
}\
}while(0);
我想作为UIViewController的类别方法,它会感觉更自然。 – vikingosegundo