UIAlertView擴展
// // UIAlertView+Extentsion.h // CloudShopping // // Created by sixiaobo on 14-7-8. // Copyright (c) 2014年 com.Uni2uni. All rights reserved. // #import <UIKit/UIKit.h> /*! * @brief UIAlertView擴展類,用於提供更加簡化的方式來調用顯示UIAlertView * @author huangyibiao */ @interface UIAlertView (Extentsion) /*! * @brief 默認會帶有確定和取消按鈕 * @param message 標題 */ + (void)showWithMessage:(NSString *)message; /*! * @brief 默認會帶有確定和取消按鈕,需要標題和內容參數 * @param title 標題 * @param message 內容 */ + (void)showWithTitle:(NSString *)title message:(NSString *)message; /*! * @brief 默認會帶有確定和取消按鈕,需要標題和內容參數 * @param title 標題 * @param message 內容 * @param delegate 代理 */ + (void)showWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate; /*! * @brief 需要標題和內容參數,確定和取消按鈕標題 * @param title 標題 * @param message 內容 * @param okButtonTitle 確定標題 */ + (void)showWithTitle:(NSString *)title message:(NSString *)message okButton:(NSString *)okButtonTitle cancelButton:(NSString *)cancelButtonTitle; /*! * @brief 需要標題和內容參數,代理,確定和取消按鈕標題 * @param title 標題 * @param message 內容 * @param delegate 代理 */ + (void)showWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate okButton:(NSString *)okButtonTitle cancelButton:(NSString *)cancelButtonTitle; @end
// // UIAlertView+Extentsion.m // CloudShopping // // Created by sixiaobo on 14-7-8. // Copyright (c) 2014年 com.Uni2uni. All rights reserved. // #import "UIAlertView+Extentsion.h" #define kOkButtonDefaultTitle @"確定" #define kCancelButtonDefaultTitle @"取消" @implementation UIAlertView (Extentsion) + (void)showWithMessage:(NSString *)message { [self showWithTitle:nil message:message]; return; } + (void)showWithTitle:(NSString *)title message:(NSString *)message { [self showWithTitle:title message:message delegate:nil]; return; } + (void)showWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate { [self showWithTitle:title message:message okButton:kOkButtonDefaultTitle cancelButton:kCancelButtonDefaultTitle]; return; } + (void)showWithTitle:(NSString *)title message:(NSString *)message okButton:(NSString *)okButtonTitle cancelButton:(NSString *)cancelButtonTitle { [self showWithTitle:title message:message delegate:nil okButton:okButtonTitle cancelButton:cancelButtonTitle]; return; } + (void)showWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate okButton:(NSString *)okButtonTitle cancelButton:(NSString *)cancelButtonTitle { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:okButtonTitle, nil]; [alertView show]; return; } @end
最後更新:2017-04-03 05:39:42