English 中文(简体)
UINavig 主计长在高级职位上存在额外地位差距
原标题:UINavigationController has extra status bar gap at top

在我设立这一机制时,这种考虑就足够简单,但我无法解释,为什么这一差距存在于地位限制和航道之间。 而且,这些观点认为,它可能得到适当调整,它只是倒塌的 bar。 这一差距与地位谈判的规模相类似,因此,我期望与它有某种关系,但我不知道什么。

“Nav

Here is the code for setting up the navigation controller:

- (void)viewDidLoad
{
    [super viewDidLoad];

    advancedVC = [[AdvancedSearchFormVC alloc] initWithNibName:@"AdvancedSearchForm" bundle:nil];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:advancedVC];
    nav.navigationBar.tintColor = [UIColor defaultNavBarTint];
    nav.navigationBar.topItem.title = NSLocalizedString(@"SearchTitle", nil);
    UIBarButtonItem *searchButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"SearchButton", nil) style:UIBarButtonItemStylePlain target:self action:@selector(refreshPropertyList:)];          
    nav.navigationBar.topItem.rightBarButtonItem = searchButton;

    self.view = nav.view;
}

该根意见库使用了从轴心档案中得出的一种观点,当时我模拟了地位条码、导航条码和表格。

最佳回答

这一问题通过确定加入导航控制器的方式得到解决。 不应把它插入已交给禁忌控制器的观点,而是应当将纳维加尼控制器直接交给导航控制员。

advancedSearchFormVC = [[AdvancedSearchFormVC alloc] initWithNibName:@"AdvancedSearchForm" bundle:nil];
UINavigationController *searchNavController = [[UINavigationController alloc] initWithRootViewController:advancedSearchFormVC];

This is just one controller that is on the tabbar controller, replacing the advancedSearchFormVC at the same time. Then this nav controller was added to the array of controllers that got put onto the tabbar controller.

解决任何麻烦,但这是我可以直接研究、而不是看到的问题之一。 我早就应该看到这一点,因为我已经把另外一名纳夫控制员放在了禁忌控制器上,而且这种控制方式也一样。

感谢你们的援助。

问题回答

问题确实是,导航控制员总是希望离开地位谈判室,这是20个星座空白。 在我找到这一解决办法之前,我用了一段时间搜索:

//nav is assumed to be a subclass or instance of UINavigationController
nav.view.frame = CGRectOffset(nav.view.frame, 0.0, -20.0);
//you can then add the navigation s view as a subview to something else

我最初找到了一种答案,这种答案是对航行禁运的看法的抵消,但却是徒劳的。 当你对导航控制员的实际看法采取行动时,它就发挥了作用。

I use this technique to add a navigation controller from another nib to an empty view of my main nib, so I can position it anywhere within the main screen as a subview. By using an empty view as a placeholder and positioning frame on my main nib, I create a separate nib and class to manage the navigation, which manages other nibs used to handle their screens. This way I can solve the classic "how do I add a banner, image, or custom views above my navigation controller" while having a navigation controller as a subview...in iOS 5 to be specific.

还值得一提的是,我利用该代表储存和接触所有其他控制人员,因此,他们被坚持不懈地保留,我可以从任何类别上进入。 在各位控制员的推荐中创造和综合一些财产,而DidLoad则造成这种情况。 因此,我可以提及我稍后在任何地方使用的所有控制器,增加:

//this shows how to store your navigation controllers in the app delegate
//assumes you ve added 2 properties (UINavigationController*)"navController" and (UIViewController*)"rootController" in your app delegate
//...don t forget to add #import "AppDelegate.h" to the top of the file

AppDelegate *app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[app.navController pushViewController: app.rootController animated:YES];
//now apply the offset trick to remove the status gap
app.navController.view.frame = CGRectOffset(app.navController.view.frame, 0.0, -20.0);

我前面还有同样的问题。 代码一用于将“UINavigation Bar”添入“IDViewController”:

UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:self];
[self.view  addSubview:nc.view];

Solution:
Check the box "Wants Full Screen" with Attributes inspector of your UIViewController.

您可尝试从Attributes <>/em>. Section of UIViewController上调<>

As we all know by now, the 20 pixel shift is to provide space for the Status bar on the top. But infact, the view controllers coordinate system is kept in place and only the navigation bar frame is shifted down by 20 pixels. This makes the navigation bar to actually overlap the top 20 pixels of the view.

航道标本的标定将显示(0.0,20.0)

因此,解决办法是简单地将航道原地重新定位到(0.0、0.0)在GiWillAppear。

self.navigationController.navigationBar.frame = CGRectMake(0.0, 0.0, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height);

由于您将advancedVC作为subview of Self.view,该编码正在的范围之内添加,而Im guessing已在对地位条码进行补偿。

也许可以通过增加这一行文来方便地确定这一点:

nav.view.frame = self.view.frame;

Just above this line:

self.view = nav.view;

-

< Other//

我对你的整个设置不征税,但<代码>本身.view根本不需要。 简言之,请见advancedVC,例如rootViewController of the UIWindow, 载于您的申请书。

The problem is that UINavigationController.view should be added to the top view. Just find the top one and it will be working great.





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...