那个突然灵光一现的时刻让我真正地摆脱了这个问题。我在代码中创建了一个 NavigationController
。附加了一个 rootviewcontroller
,它创建了一个 tableview
(也在代码中)。这一切都按预期工作。 tableview
呈现,从右侧滑入等选项加载等。
然后,当我在第一个 tableview
中选择一个选项来加载 UIView
(没有表格,只有一些图像)时,这就是我得到的(ahhhh .. . 无法显示,因为我显然需要 10 个声望才能发布图像...叹息!)。
无论如何, View 是从右侧插入的。但是, View 的内容被导航栏(部分)屏蔽了。太高了。
我用来创建这个问题的代码如下所示:
SearchMainTableViewController.h
#import <UIKit/UIKit.h>
#import "CRPSearchMainTableViewController.h"
@interface CRPSearchMasterViewController : UINavigationController
@property (strong, nonatomic) UINavigationController *myNavigationController;
@property (strong, nonatomic) CRPSearchMainTableViewController *myMainTableViewController;
@end
SearchMainTableViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
_myMainTableViewController = [[CRPSearchMainTableViewController alloc] initWithNibName:nil bundle:nil];
myNavigationController = [[UINavigationController alloc] initWithRootViewController:_myMainTableViewController];
[self.view addSubview:myNavigationController.view];
}
在我的 SearchMainTableViewController 中我有:
#import "CRPRegistrationMasterViewController.h"
#import "CRPFixedSearchViewController.h"
#import "CRPSettingsPickerViewController.h"
@interface CRPSearchMainTableViewController : CRPRegistrationMasterViewController <UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) UITableView *myTableView;
@property (strong, nonatomic) CRPFixedSearchViewController *myFixed;
@property (strong, nonatomic) CRPSettingsPickerViewController *mySettingsPicker;
@end
以及 SearchMainTableViewController.m 的部分:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"Settings";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(loadNext)];
myTableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
myTableView.delegate = self;
myTableView.dataSource = self;
[myTableView registerNib:[UINib nibWithNibName:@"settingsTableCell" bundle:nil] forCellReuseIdentifier:tableCell];
myParams = [self getSearchParams];
if (myParams){
NSLog(@"I have params");
} else {
NSLog(@"I don't have params");
// First time of running this
SearchParams *params = [NSEntityDescription insertNewObjectForEntityForName:@"SearchParams" inManagedObjectContext:_myManagedObjectContext];
if (params != nil)
{
NSError *paramsError = nil;
if ([_myManagedObjectContext save:¶msError])
{
NSLog(@"I have added a SearchParams field in the table");
} else {
NSLog(@"I have a problem with adding Search Params into the table: %@", [paramsError userInfo]);
}
} else {
NSLog(@"Cannot get entity");
}
}
[self.view addSubview:myTableView];
}
...
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
switch (indexPath.row) {
case 2:
{
mySettingsPicker = [[CRPSettingsPickerViewController alloc] initWithNibName:@"SettingsPicker" bundle:nil];
[self.navigationController pushViewController:mySettingsPicker animated:YES];
}
break;
CRPSettingsPickerViewController
是一个简单的 Controller 。我没有添加任何代码。我只是想看看 View 是否会正确加载(我无法显示,因为我没有 10 叹息的声誉)。
任何帮助都会很棒。我有一种感觉,我错过了一些小东西。我在任何项目中遇到的所有问题都围绕着 TableViews
。看来他们是我的克星。
干杯
最佳答案
我发现在 iOS7 中使用 UINavigationBar 时,半透明设置将导致导航 View 从 0,0 开始,而不是使用 64,0 对其进行分解。如果你改变
Translucent = NO;
您的 UINavigation 栏不会覆盖您的新 View 。我遇到过同样的问题: Here
祝你好运!
关于ios - 无法停止覆盖推送 View 的导航栏 - 为什么会这样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20961413/