1

ナビゲーションバーを備えた新しいアプリの作成を始めたばかりです。のナビゲーションで最初のビューを作成しましたAppDelegate.m

AppDelegate.m :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    sleep(2);
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:[[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]];
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];
    return YES;
}

次に、メソッド内の HomeViewController のビューを作成しますloadView

HomeViewController の LoadView :

- (void)loadView
{
    self.view = [[UIView alloc] init];
    self.view.backgroundColor = [UIColor whiteColor];
    self.searchPoiInstructionsLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
    self.searchPoiInstructionsLabel.layer.borderColor = [UIColor blackColor].CGColor;
    self.searchPoiInstructionsLabel.layer.borderWidth = 2.0f;
    self.searchPoiInstructionsLabel.text = @"HELLO WORLD";
    [self.view addSubview:self.searchPoiInstructionsLabel];
}

ラベル Hello World が表示されない...

ここに画像の説明を入力

フレームにCGRectMake(0, 65, 50, 20)65forを設定するyと、「Hello World」が表示されます...(わかっています、幅を増やさなければなりません:))

ここに画像の説明を入力

私は自分の見解の起源を理解していません.誰かが私を説明できるなら.

ありがとう

4

3 に答える 3

0
- (void)viewDidLoad
{
    [super viewDidLoad];
    if ([[[[UIDevice currentDevice]systemVersion] componentsSeparatedByString:@"."][0] intValue] >=7)    {
      if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
      }
    }
}
于 2014-06-05T03:53:52.773 に答える