看來你正在更新你的解析loginView。我遇到了同樣的問題......讓默認的loginView適合所有屏幕設備尺寸真的很痛苦。我會分享一些我希望能幫到的代碼。這應該在Parse的IOS幫助頁面上。 將這個在您的.m文件
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
//Returns the screen dimensions (in points) of the user's current device
CGRect screenBounds = [[UIScreen mainScreen] bounds];
//Finds to see if the user has an iPhone 4s, and then set's the layout if they do
if(screenBounds.size.height==480)
{
[self.logInView.logInButton setFrame:CGRectMake(self.view.center.x - 125, 300.0f, 250.0f, 50.0f)];
[self.logInView.usernameField setFrame:CGRectMake(self.view.center.x - 125, 165.0f, 250.0f, 50.0f)];
[self.logInView.passwordField setFrame:CGRectMake(self.view.center.x - 125, 215.0f, 250.0f, 50.0f)];
[self.logInView.passwordForgottenButton setFrame:CGRectMake(self.view.center.x - 125, 265.0f, 250.0f, 40.0f)]; }
//Finds to see if the user has an iPhone 5/5s, and then set's the layout if they do
else if (screenBounds.size.height == 568)
{
[self.logInView.logInButton setFrame:CGRectMake(self.view.center.x - 125,360.0f, 250.0f, 50.0f)];
[self.logInView.usernameField setFrame:CGRectMake(self.view.center.x - 125, 245.0f, 250.0f, 50.0f)];
[self.logInView.passwordField setFrame:CGRectMake(self.view.center.x - 125, 295.0f, 250.0f, 50.0f)];
[self.logInView.passwordForgottenButton setFrame:CGRectMake(self.view.center.x - 125, 445.0f, 250.0f, 40.0f)]; }
//If the user doesn't have a 4S/5/5s, then they must be using an iPhone 6/6+
else {
[self.logInView.logInButton setFrame:CGRectMake(self.view.center.x - 125, 420.0f, 250.0f, 50.0f)];
[self.logInView.usernameField setFrame:CGRectMake(self.view.center.x - 125, 275.0f, 250.0f, 50.0f)];
[self.logInView.passwordField setFrame:CGRectMake(self.view.center.x - 125, 325.0f, 250.0f, 50.0f)];
[self.logInView.passwordForgottenButton setFrame:CGRectMake(self.view.center.x - 125, 485.0f, 250.0f, 40.0f)];
//Prints out the current device being used
NSLog(@"Current device: %@", [[UIDevice currentDevice] model]);
}
基地的幀座標(x和y)關閉父視圖的框架,而不是硬編碼值。 – rmaddy
或使用Autolayout。 – Abizern
您可能需要在viewDidLayoutSubviews中設置中心。此時你會知道父母的真實框架。 –