Objective c UI初始化时屏幕外搜索栏-iPad

Objective c UI初始化时屏幕外搜索栏-iPad,objective-c,xcode,ipad,ios6,uisearchbar,Objective C,Xcode,Ipad,Ios6,Uisearchbar,我有以下代码在iOS5下工作,用于在iPad的UITableView顶部放置UISearchBar: - (void)viewDidLoad { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { CGRect searchViewFrame = CGRectMake(33, 33, 264, 45); UIView *containerSearch = [[UIView alloc]

我有以下代码在iOS5下工作,用于在iPad的UITableView顶部放置UISearchBar:

- (void)viewDidLoad
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

        CGRect searchViewFrame = CGRectMake(33, 33, 264, 45);
        UIView *containerSearch = [[UIView alloc] initWithFrame: searchViewFrame];
        searchBar = [[UISearchBar alloc] init];
        searchBar.barStyle = UIBarStyleDefault;
        [containerSearch addSubview: searchBar];
        self.tableView.tableHeaderView = containerSearch;

        searchController = [[UISearchDisplayController alloc]
                            initWithSearchBar:searchBar
                            contentsController:self];

        searchBar.delegate = self;
        searchController.delegate = self;
        searchController.searchResultsDelegate=self;
        searchController.searchResultsDataSource=self; 

        [searchBar release];
    }  
然而,在iOS6下,这段代码的行为异常。当iPad以横向模式启动时,UISearchBar将脱离屏幕。在ipad旋转到纵向和横向之前,它不会出现在正确的位置

这只是一个iOS6错误还是关于如何修复它的任何建议


谢谢

您是否尝试过用框架初始化搜索栏<代码>搜索栏=[[UISearchBar alloc]initWithFrame:CGRectMake(0,0265,45)]

您是否尝试使用框架初始化搜索栏<代码>搜索栏=[[UISearchBar alloc]initWithFrame:CGRectMake(0,0265,45)]谢谢-似乎已经完成了任务。不客气!我把它贴出来作为答复。