PFLoginViewController Jumbled on iPhone 4S Screen

89 Views Asked by At

I have subclassed PFLoginViewController in my app with the code below. On a 5S or 6 device, everything looks as it should. However, on a 4S or lower device, some buttons are too high, some are too low, so much that you can't even see the Sign Up button. Could someone check out my framing and see if there's a way I could do it better to make it all fit across all devices?

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor blackColor];

    UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]" ]];
    self.logInView.logo = logoView; // logo can be any UIView
    self.fieldsBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"LoginFieldBG.png"]];
    UITextView *iprayed = [[UITextView alloc] initWithFrame:CGRectMake(0, 120, 320, 40)];
    iprayed.text = @"iPrayed 4 U";
    iprayed.textAlignment = NSTextAlignmentCenter;
    iprayed.textColor = [UIColor whiteColor];
    iprayed.backgroundColor = [UIColor blackColor];
     UIFont *cellFont = [UIFont fontWithName:@"Verdana-Bold" size:25];
    iprayed.font = cellFont;
    [self.logInView addSubview:iprayed];
    [self.logInView insertSubview:self.fieldsBackground atIndex:1];
}
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    CALayer * l = [self.logInView.logo layer];
    [l setMasksToBounds:YES];
    [l setCornerRadius:40];
    [l setBorderWidth:2.0];
    [l setBorderColor:[[UIColor whiteColor] CGColor]];

    // Set frame for elements
    [self.logInView.dismissButton setFrame:CGRectMake(10.0f, 10.0f, 87.5f, 45.5f)];
    [self.logInView.logo setFrame:CGRectMake(120, 40, 80, 80)];
    [self.logInView.facebookButton setFrame:CGRectMake(35.0f, 400.0f, 120.0f, 40.0f)];
    [self.logInView.twitterButton setFrame:CGRectMake(35.0f+130.0f, 400.0f, 120.0f, 40.0f)];
    [self.logInView.signUpButton setFrame:CGRectMake(35.0f, 490.0f, 250.0f, 40.0f)];
    [self.logInView.usernameField setFrame:CGRectMake(35.0f, 175.0f, 250.0f, 50.0f)];
    [self.logInView.passwordField setFrame:CGRectMake(35.0f, 225.0f, 250.0f, 50.0f)];
    [self.fieldsBackground setFrame:CGRectMake(35.0f, 175.0f, 250.0f, 100.0f)];
    [self.logInView.passwordForgottenButton setFrame:CGRectMake(0.0f, 200.0f, 35.0f, 40.0f)];
}

iPhone 5S: enter image description here

iPhone 4S: enter image description here

0

There are 0 best solutions below