이전 iOS 앱의 일부 코드 + xib 레이아웃을 현재 앱과 병합 중입니다.xib 레이아웃을 확장하여 화면 채우기
모두 iPhone 5/6의 레이아웃과 별개입니다. 원래 앱은 해당 화면에 맞게 확장됩니다. 그러나 현재 앱의 새 버튼에서 시작된 이전 앱에서보기 컨트롤러의 하위 집합 만 사용하고 있습니다.
내가보고있는 것은 iPhone 4 크기 레이아웃이 예를 들어 화면 왼쪽 상단을 차지하는 것입니다. 아이폰 6, 이전 코드에서보기 컨트롤러가로드 될 때.
여러 가지 시도를했습니다. 약간의 차이를 만든 한 가지 기존 응용 프로그램의되는 SplashScreen의 코드를 찾고 있었어요 :
- (void)loadView
{
[[[NSBundle mainBundle] loadNibNamed:@"HomeScreenViewController" owner:self options:nil] objectAtIndex:0];
self.view.autoresizesSubviews = YES;
[self.view setTranslatesAutoresizingMaskIntoConstraints:NO];
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
UIImage* backgroundImage = [UIImage imageNamed:@"Default-no-logo.png"];
self.view.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
[self.view setFrame:appFrame];
}
:
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
//Init the View
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
UIView *view = [[UIView alloc] initWithFrame:appFrame];
view.autoresizingMask = UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth;
self.view = view;
[view release];
NSString *splashImageName = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
splashImageName = @"iPadDefault2.png";
else
splashImageName = @"Default.png";
mSplashImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:splashImageName]];
[self.view addSubview:mSplashImageView];
}
그래서 나는 새로운 응용 프로그램에서 실행 뷰입니다
HomeScreenViewController
에 다음을 추가
이제 iPhone 6의 공간을 채우기 위해 배경 이미지가 바뀌었지만 인터페이스는 왼쪽 상단의 위치와 크기가 동일합니다.
나는 사용자 정의 UIView를 만드는 UIView added programmatically full screen wrong size과 같은 대답을 보았지만 내 상황에는 도움이되지 않습니다.
편집 :
NSString *splashImageName = nil;
splashImageName = @"Default-no-logo.png";
mSplashImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:splashImageName]];
mSplashImageView.contentMode = UIViewContentModeScaleAspectFit;
[mSplashImageView setFrame:appFrame];
[self.view addSubview:mSplashImageView];
내가 이미지 쇼 전체 화면을 얻을 : 나는 loadView
방법을 변경하는 경우
. 그러나 사용자 지정 UIView 함께 이렇게 작동하지 않습니다. autoresizingMask
을 존중하고 더 큰 디스플레이로 성장하기 위해 UIView를 얻으려면 어떻게해야합니까? 나는 아이폰 6, 다양한 장소에서 디버그 포인트를 설정 한
은 항상 높이가 대답 안 667
확인 콘센트 –
기본적으로 제거와 출구의 새 인스턴스를 만들하시기 바랍니다 콘센트 문제는 –