我创建了一个基于导航控制器的应用程序。在导航栏下方打开的视图有一个 UIImageView 和一组用于导航目的的 uiimage 顶部的“详细信息披露”按钮。
我注意到的是,当这些按钮出现在模拟器中时,它们已经偏离了它们的设计者(界面构建器)位置。
我怀疑导航栏与它有关,但它们不会与导航栏的高度成比例地向下移动。
我不知道如何告诉他们坚持自己的立场。
即使顶部有导航栏, UIImage 也不会溢出屏幕的高度。
在使用顶部的导航栏时,他们是否需要了解任何指南/陷阱?
我正在使用 xcode 4
谢谢
编辑:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
StartScreenViewController *controller =
[[StartScreenViewController alloc] initWithNibName:@"StartScreenViewController" bundle:nil];
_navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
_navigationController.view.frame = CGRectMake(0,0, 320, 460);
_navigationController.title = @"Test";
//[self.window addSubview:_navigationController.view];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
另一件事是,如果我使用“addsubview”方法,那么导航栏会被截断,而如果我将导航控制器分配给 window.rootviewcontroller,那么我会看到整个导航栏。
编辑 2
这是我的 AppDelegate.h 的样子
@interface TestAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIView *mainView;
}
@property (nonatomic, retain) IBOutlet UIView *mainView;
@property (nonatomic, retain) IBOutlet UIWindow *window;
//@property (nonatomic, retain) IBOutlet UIViewController *viewController;
@end
这是 AppDelegate.m 的 didFinishLaunchingWithOptions 方法
StartScreenViewController *controller = [[StartScreenViewController alloc] initWithNibName:@"StartScreenViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
navController.title = @"Test";
navController.view.frame = CGRectMake(0, 0, 320, 460);
[self.mainView addSubview:navController.view];
[self.window makeKeyAndVisible];
MainWindow.xib 包含 App 委托和作为对象的窗口。Window 下面有一个 UIView。
StartScreenViewcontroller 的 xib 文件有 UIImageview 和按钮。