| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- //
- // RetrievePasswordViewController.m
- // Apex Mobile
- //
- // Created by Ray on 14-3-17.
- // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
- //
- #import "RetrievePasswordViewController.h"
- @interface RetrievePasswordViewController ()
- @end
- @implementation RetrievePasswordViewController
- - (IBAction)OnCancel:(UIButton *)sender {
- [self dismissViewControllerAnimated:true completion:^{
- ;
- }];
- }
- - (BOOL)shouldAutorotate
- {
- return YES;
- }
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations
- {
- return UIInterfaceOrientationMaskPortrait;
- }
- - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
- {
- return UIInterfaceOrientationPortrait;
- }
- - (IBAction)OnOk:(UIButton *)sender {
-
- NSString* user = self.editUser.text;
- NSString* email = self.editEmail.text;
- if(user.length==0||email.length==0)
- {
-
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", @"Error") message:NSLocalizedString(@"alert_msg_uecanotempty", @"User&Email can not be empty!") preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", @"Ok") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- [alertVC addAction:action];
-
- [self presentViewController:alertVC animated:YES completion:nil];
-
- return;
- }
-
- self.btnOk.enabled = false;
- self.btnCancel.enabled=false;
-
- self.mum.hidden=false;
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
-
- int ret = [RADataProvider requestRetrievePassword:user email:email];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- self.mum.hidden=true;
- self.btnOk.enabled = true;
- self.btnCancel.enabled=true;
-
- if (ret==RESULT_TRUE)
- {
-
-
- [self dismissViewControllerAnimated:true completion:^{
-
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_retrieve_success", @"Retrieve successfully!!") message:NSLocalizedString(@"alert_msg_email_sent", @"Email has been sent.") preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", @"Ok") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- [alertVC addAction:action];
-
- // AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- // [appDelegate.window.rootViewController presentViewController:alertVC animated:YES completion:nil];
- }];
- }
- else
- {
-
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", @"Error") message:[NSString stringWithFormat:NSLocalizedString(@"alert_msg_failed_retrieve_password", @"Failed to retrieve password code %d"),ret] preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", @"Ok") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- [alertVC addAction:action];
-
- [self presentViewController:alertVC animated:YES completion:nil];
- }
-
-
-
- });
- });
- }
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
- [[self view] endEditing:YES];
- }
- -(BOOL)textFieldShouldReturn:(UITextField *)textField {
-
- [textField resignFirstResponder];
- return YES;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
- {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|