Tuesday, December 15, 2015

How to create Forgot Password Default Alert Popup for all iOS Apps



//Declare in .h file
NSString * forgotPasswordAlertText;

//Forgot Password button Actions Methods
- (IBAction)forgotPasswordButtonTapped:(id)sender{

    UIAlertView * altView = [[UIAlertView allocinitWithTitle:@"Forgot Password?"message:@"Please enter your email address." delegate:self cancelButtonTitle:@“Cancel"otherButtonTitles:@"OK"nil];
    altView.tag = 101;
    [altView setAlertViewStyle:UIAlertViewStylePlainTextInput];
    [altView textFieldAtIndex:0].placeholder = @"Email Address";
    [altView textFieldAtIndex:0].keyboardType = UIKeyboardTypeEmailAddress;
    [altView textFieldAtIndex:0].returnKeyType = UIReturnKeyDone;
    [altView textFieldAtIndex:0].text = forgotPasswordAlertText;
    [altView show];
}

#pragma mark Alert view Delegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (alertView.tag) {
        //101 tag for forgot password
        case 101:
            switch (buttonIndex) {
                case 1:
                    forgotPasswordAlertText = [alertView textFieldAtIndex:0].text;
                    if (![self validateEmail:forgotPasswordAlertText]){
                        showAlertOkAction@"Check Email"@"Please Enter Proper Username");
                    }else{
                        //call web service method from here
                        forgotPasswordAlertText = @"";
                    }
                    break;
                    
                default:
                    break;
            }
            break;
        //102 tag for reopen forgot password alert
        case 102:
            [self forgotPasswordButtonTapped:nil];
            
        default:
            break;
    }
}

//For Email Validation

-(BOOL)validateEmail:(NSString*)email{
    
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    BOOL isValid = [emailTest evaluateWithObject:email];
    
    return isValid;
}


//Declare in Constant File


#define showAlertOkAction(messageT,title) UIAlertView *alert=[[UIAlertView alloc] initWithTitle:messageT message:title delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil, nil];[alert show];alert.tag = 102;alert.delegate = self;

Screenshots size for upload application to App Server in iOS (ALL Device)



The iPhone 6 and iPhone 6 Plus screenshots don't accept cropped (without status bar) uploads.

5.5in (iPhone 6 Plus):
1242 × 2208px portrait

4.7in (iPhone 6):
750 × 1334px portrait

4in (iPhone 5 and 5s):
640 × 1096px portrait (without status bar) minimum
640 × 1136px portrait (full screen) maximum
1136 × 600px landscape (without status bar) minimum
1136 × 640px landscape (full screen) minimum

3.5in (iPhone 4 and 4s):
640 × 920px portrait (without status bar) minimum
640 × 960px portrait (full screen) maximum
960 × 600px landscape (without status bar) minimum
960 × 640px landscape (full screen) maximum