#import"AppUtils.h"
#include"RIButtonItem.h"
#include"UIAlertView+Blocks.h"
@implementationAppUtils
//彈出警告框,並實現警告框按鈕的觸發事件
-(void)showInputDialogWithTitle:(NSString*)titlemessage:(NSString*)messagetoAlertView:(UIAlertView*)alertconfirmAction:(void(^)(void))action{
RIButtonItem*cancelItem=[RIButtonItemitem];
cancelItem.label=@"No";
cancelItem.action=^
{
//為NO時的處理
UITextField*tf=[alerttextFieldAtIndex:0];
NSLog(@"UITextField=%@",tf.text);
};
RIButtonItem*confirmItem=[RIButtonItemitem];
confirmItem.label=@"Yes";
//confirmItem.action=action;
alert=[alertinitWithTitle:title
message:message
cancelButtonItem:cancelItem
otherButtonItems:confirmItem,nil];
alert.alertViewStyle=UIAlertViewStylePlainTextInput;
confirmItem.action=action;
[alertshow];
}
@end
#import "AppUtils.h" #include "RIButtonItem.h" #include "UIAlertView+Blocks.h" @implementation AppUtils //彈出警告框,並實現警告框按鈕的觸發事件 - (void)showInputDialogWithTitle:(NSString *)title message:(NSString *)message toAlertView:(UIAlertView*) alert confirmAction:(void(^)(void))action{ RIButtonItem* cancelItem = [RIButtonItem item]; cancelItem.label = @"No"; cancelItem.action = ^ { //為NO時的處理 UITextField *tf=[alert textFieldAtIndex:0]; NSLog(@"UITextField=%@",tf.text); }; RIButtonItem* confirmItem = [RIButtonItem item]; confirmItem.label = @"Yes"; // confirmItem.action = action; alert = [alert initWithTitle:title message:message cancelButtonItem:cancelItem otherButtonItems:confirmItem, nil]; alert.alertViewStyle = UIAlertViewStylePlainTextInput; confirmItem.action = action; [alert show]; } @end