Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios7 使用标准UITableView控制器,UITableView标题将消失在UINavigationBar下_Ios7_Uiviewcontroller_Uitableview_Uisearchbar - Fatal编程技术网

Ios7 使用标准UITableView控制器,UITableView标题将消失在UINavigationBar下

Ios7 使用标准UITableView控制器,UITableView标题将消失在UINavigationBar下,ios7,uiviewcontroller,uitableview,uisearchbar,Ios7,Uiviewcontroller,Uitableview,Uisearchbar,我在UINavigationController中有一个UITableViewController。我添加了一个ui搜索栏作为tableView.header: UISearchBar *searchBar = [UISearchBar alloc] initWithFrame: CGRectMake(0,0,self.tableView.frame.size.width,44.0)]; self.tableView.tableHeaderView = searchBar; 问题:滚动时,ta

我在
UINavigationController
中有一个
UITableViewController
。我添加了一个
ui搜索栏作为
tableView.header

UISearchBar *searchBar = [UISearchBar alloc] initWithFrame: CGRectMake(0,0,self.tableView.frame.size.width,44.0)];
self.tableView.tableHeaderView = searchBar;
问题:滚动时,tableHeader在导航栏下消失

我已经尝试过设置
navigationController.navigationBar.translucent=NO
,但是使用标准的UITableViewController,这个技巧似乎不起作用


有没有办法使用标准的UITableViewController解决此问题?我希望它的工作原理完全一样,它在联系人应用程序。我的目标是iOS7。

我放弃了使用
UITableViewController
,我使用了一个标准的
UIViewController
,上面有一个
UISearchBar
,下面有一个
UITableView
。通过设置self.edgesForExtendedLayout=UIRectEdgeNone
搜索开始时,
UISearchBar
不会与状态栏重叠:

-(id) initWithTableViewStyle: (int) tableViewStyle
{
    self = [super init];
    if (self) {

        //Set the UITableViewStyle
        self.tableViewStyle = tableViewStyle;

        //Be sure the searchBar won't overlap the status bar
        self.edgesForExtendedLayout = UIRectEdgeNone;

        //Add the subviews to the mainView
        [self.view addSubview:self.searchBar];
        [self.view addSubview:self.tableView];

        //Autolayout

        //Create the views dictionary
        NSDictionary *viewsDictionary = @{@"searchBar":self.searchBar,
                                          @"tableView": self.tableView};

        //Create the constraints using the visual language format
        [self.view addConstraints:[NSLayoutConstraint
                                   constraintsWithVisualFormat: @"H:|[searchBar]|"
                                   options:0
                                   metrics:nil
                                   views:viewsDictionary]];

        [self.view addConstraints:[NSLayoutConstraint
                                   constraintsWithVisualFormat: @"H:|[tableView]|"
                                   options:0
                                   metrics:nil
                                   views:viewsDictionary]];

        [self.view addConstraints:[NSLayoutConstraint
                                   constraintsWithVisualFormat:@"V:|[searchBar(==44)][tableView]|"
                                       options:0
                                       metrics:nil
                                       views:viewsDictionary]];
    }
    return self;

}

-(UITableView*) tableView
{
    if (!_tableView){

        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,0,0)
                                                  style:self.tableViewStyle];
        _tableView.translatesAutoresizingMaskIntoConstraints=NO;
        _tableView.delegate = self;
        _tableView.dataSource=self;
    }
    return _tableView;
}

-(UISearchBar*) searchBar
{
    if(!_searchBar){

        _searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,0,0,0)];
        _searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
        _searchBar.translatesAutoresizingMaskIntoConstraints=NO;
        _searchBar.translucent = NO;
        _searchBar.delegate = self;
    }
    return _searchBar;
}
UIViewController应制作为:

UIViewController <NSFetchedResultsControllerDelegate,
                                          UISearchBarDelegate,
                                          UISearchDisplayDelegate,
                                          UITableViewDataSource,
                                          UITableViewDelegate>
UIViewController