导航控制器的 iPhone UI 设计 - 按钮向下移动

发布于 2024-11-08 01:06:16 字数 2143 浏览 1 评论 0原文

我创建了一个基于导航控制器的应用程序。导航栏下方打开的视图有一个 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 和按钮。

I created a navigation controller based app. The view that opens up below the nvigation bar has a UIImageView and a bunch of 'detail disclosure' buttons on top of te uiimage for navigation purposes as well.

What I am noticing is that these buttons s have deviated down from their designer (interface builder) position when they come up in the simulator.

I suspect the navigation bar has something to do with it, but they don't move down proportional to the height of the navigation bar.

I am not sure how to tell them to hold on to their position.

The UIImage does not overflow the height of the screen even with the navigaion bar at the top.

Are their any guidelines/gotchas one needs to know about when using navigation bar at the top?

I am using xcode 4

Thanks

Edit:

- (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;
}

Another thing is that if I use the 'addsubview' method then the nav bar is truncated while if I assign the nav controller to window.rootviewcontroller then I see the whole nav bar.

Edit 2

Here how my AppDelegate.h looks

@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

Here is the AppDelegate.m's didFinishLaunchingWithOptions method

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];

The MainWindow.xib contains App delegate and the window as the objects. the Window has a UIView underneath it.

StartScreenViewcontroller's xib file has the UIImageview and the buttons.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人心善变 2024-11-15 01:06:16

拍摄一些屏幕截图,看看它们向下移动了多远。如果是 20px 那么这是很多人(包括我自己)都遇到过的问题。我通过将视图重新定义为与 IB 中的大小相同来修复它。出于某种原因,iPhone 试图变得智能并帮助您调整事物的大小,但有时它会做错。

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
                navController.view.frame = CGRectMake(0, 0, 320, 460);
[self.window addSubview:navController.view];

如果这不起作用,请尝试以下搜索:https://stackoverflow.com/search?q=%5Biphone %5D+20px

编辑:
我这里漏掉了一块。为了解决这个问题,我必须将 UIView 添加到 MainWindow.xib 文件中......

1. 在 AppDelegate.h 中,为 IBOutlet UIView *mainView
创建一个属性
2. 为其执行 @property 操作并将其合成到 .m 文件中
3.打开MainWindow.xib
4. 将 UIView 拖到窗口上(不是 ViewController)并使其适合整个框架
5. 在IB中的Documents窗口中右键单击AppDelegate对象,并将mainView属性连接到刚刚添加的UIView。
6. 现在在 AppDelegate.m...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
    navController.view.frame = CGRectMake(0, 0, 320, 460);

    //[self.window addSubview:navController.view]; // old broken way
    [mainView addSubview:navController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

和 AppDelegate.h 中:

@interface TestNavigationAppAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    TestNavigationAppViewController *viewController;
    IBOutlet UIView *mainView;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet TestNavigationAppViewController *viewController;
@property (nonatomic, retain) IBOutlet UIView *mainView;

Take some screen shots and see how far they are being moved down. If its 20px then this is a problem that tons of people have had (including myself). I fixed it by redefining the view to be the same size that it is in IB. For some reason the iPhone tries to be smart and help you resize things and sometimes it does it wrong.

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
                navController.view.frame = CGRectMake(0, 0, 320, 460);
[self.window addSubview:navController.view];

If that doesn't work then try this search: https://stackoverflow.com/search?q=%5Biphone%5D+20px.

EDIT:
I missed a piece here. In order to get around this I had to add a UIView to the MainWindow.xib file....

1. In your AppDelegate.h, create a property for IBOutlet UIView *mainView
2. Do the @property thing for it and synthesize it in the .m file
3. Open MainWindow.xib
4. Drag a UIView onto the Window (NOT the ViewController) and make it fit the full frame
5. Right click the AppDelegate object in the Documents window in IB and connect the mainView property to the UIView you just added.
6. Now in AppDelegate.m...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
    navController.view.frame = CGRectMake(0, 0, 320, 460);

    //[self.window addSubview:navController.view]; // old broken way
    [mainView addSubview:navController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

and AppDelegate.h:

@interface TestNavigationAppAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    TestNavigationAppViewController *viewController;
    IBOutlet UIView *mainView;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet TestNavigationAppViewController *viewController;
@property (nonatomic, retain) IBOutlet UIView *mainView;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文