Ios 导航栏标题中的搜索栏查看是否在方向更改时从UINavigationItem中弹出?

Ios 导航栏标题中的搜索栏查看是否在方向更改时从UINavigationItem中弹出?,ios,ios6,uinavigationcontroller,uinavigationbar,uinavigationitem,Ios,Ios6,Uinavigationcontroller,Uinavigationbar,Uinavigationitem,我在导航栏的标题视图中添加了一个搜索栏。 除了方向改变外,它看起来不错。无论出于何种原因,搜索栏正在改变位置。这就好像搜索栏突然弹出,或者对于导航栏来说太大了。 有没有其他人遇到过这个问题,并且知道如何解决它?我正在使用故事板,想知道是否有一个设置我错过了或什么。这是我的密码: -(void) viewDidAppear:(BOOL)animated { UIImage *addImage = [UIImage imageNamed:@"reveal-icon.png"];

我在导航栏的标题视图中添加了一个搜索栏。

除了方向改变外,它看起来不错。无论出于何种原因,搜索栏正在改变位置。这就好像搜索栏突然弹出,或者对于导航栏来说太大了。

有没有其他人遇到过这个问题,并且知道如何解决它?我正在使用故事板,想知道是否有一个设置我错过了或什么。这是我的密码:

-(void) viewDidAppear:(BOOL)animated
{
    UIImage *addImage = [UIImage imageNamed:@"reveal-icon.png"];

    UIButton *addButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [addButton setFrame:CGRectMake(0, 0, addImage.size.width, addImage.size.height)];
    [addButton setBackgroundImage:addImage forState:UIControlStateNormal];

    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:addButton];
    [self.navigationItem setLeftBarButtonItem:barButtonItem];

    UIView *searchBarView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 260.0, 44.0)];
    searchBarView.autoresizingMask = 0;

    UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:searchBarView.frame];
    searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    searchBar.delegate = self;

    [searchBarView addSubview:searchBar];

    self.navigationItem.titleView = searchBar;
}

我将禁用视图上的导航栏,并将项目添加到根视图本身,而不是将内容推入导航栏。这是唯一的解决方法吗?似乎导航栏在横向方向上较短。