我刚刚开始用导航栏制作一个新的应用程序。我使用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方法中的视图。
LoadView of HomeViewController:
- (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没有出现..。

对于这个框架,如果我设置CGRectMake(0, 65, 50, 20),65表示y,我的"Hello“就会出现.(我知道,我必须增加宽度:)

我只是不明白我的观点的起源..。如果有人能解释我的话。
谢谢
发布于 2014-06-05 02:53:42
iOS 7的起源有点不同。在导航控制器中,导航栏下面的内容可以显示一些模糊效果。因此,导航控制器中标签的原点位于导航条下方的左上方(0,0)点,而不是导航条下的最左点。这是给你的演示。
发布于 2014-06-05 03:53:52
- (void)viewDidLoad
{
[super viewDidLoad];
if ([[[[UIDevice currentDevice]systemVersion] componentsSeparatedByString:@"."][0] intValue] >=7) {
if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
}
}https://stackoverflow.com/questions/24050586
复制相似问题