인터페이스 작성기없이 iOS를 개발하기 시작했습니다.iOS UIViewController 레이아웃 문제
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
ViewController *viewController = [[ViewController alloc] init];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
}
ViewController.m는
- (void)loadView
{
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
UIView *contentView = [[UIView alloc] initWithFrame:applicationFrame];
contentView.backgroundColor = [UIColor whiteColor];
self.view = contentView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 280, 20)];
[label setText:@"ViewController"];
[label setTextAlignment:NSTextAlignmentCenter];
[label setBackgroundColor:[UIColor redColor]];
[self.view addSubview:label];
}
나는 이유는 모르겠지만, 내가 응용 프로그램을로드 할 때, 상단 개미 botton을 볼 사이의 공간이있다. 왜 그런 생각을 가진 사람이 있습니까?
프로젝트에 [email protected] 배경 이미지를 추가해야합니다. –
방금 6 플러스 시뮬레이터에서 코드를 실행했습니다. 검정 영역이 보이지 않습니다. – humblePilgrim
@Gonji Dev, 답변이 맞습니다! 게시하는 경우 올바른 것으로 표시합니다. –