ios – UISearchBar到UISearchDisplayController得轉換是20px

    我正在UITableView得頂部實現一個UISearchBar.

    在我得ViewDidLoad中,我設置了self.edgesForExtendedLayout = UIRectEdgeNone.

    這是我如何添加我得UISearchBar.我只是將UISearchBar添加到我得UITableView得標題并調整內容偏移量:

    // Table Viewself.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,self.screenWidth,self.screenHeight)];self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;// Customize table appearance[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];self.tableView.backgroundColor = [UIColor tableBackgroundColor];// Define the table's datasourceself.tableView.dataSource = self;self.tableView.delegate = self;[self.view addSubview:self.tableView];// Add a search bar to the headerself.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,44)];self.searchBar.tintColor = [UIColor primaryBrandedColor];self.searchBar.placeholder = NSLocalizedString(@"Search","Search placeholder");self.searchBar.backgroundImage = [UIImage imageNamed:@"searchBarBackground"];[self.searchBar setBackgroundImage:[UIImage imageNamed:@"searchBarBackground"] forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault];self.searchBar.barTintColor = [UIColor clearColor];self.searchBar.delegate = self;[[UITextField appearanceWhenContainedIn:[UISearchBar class],nil] setFont:[UIFont fontWithName:@"Whitney-Light" size:15]];//Setup search display controllerself.searchController = [[HUMSearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];self.searchController.delegate = self;self.searchController.searchResultsDataSource = self;self.searchController.searchResultsDelegate = self;self.searchController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;// Add the searchBar and offset the table view so it's hidden by default.self.tableView.tableHeaderView = self.searchBar;self.tableView.contentOffset = CGPointMake(0.0,self.searchBar.frame.size.height);

    看起來似乎沒有任何異常,但是當顯示SearchDisplayController時,原始tableview上有20px得差距.在這個例子中,我將SearchDisplayController子類化為不隱藏NavigationBar以使其更清楚發生了什么.

    轉換得視頻捕獲:http://cl.ly/0y3L0Z1R1I0c/20pixels.mov

    我試過得東西:

    >在searchDisplayControllerWillBeginSearch上更改我得UITableView得框架,將其向上移動20px.這打破了過渡. http://cl.ly/033q0L3G0p1T/origin.mov
    >在searchDisplayControllerWillBegin上更改UITableView上得滾動偏移.同樣,這打破了過渡.
    >嘗試手動設置UISearchBar得動畫,但我無法使其工作.

    有任何想法嗎?

    解決方法

    經過幾次試錯會后,我終于達到了預期得行為.在我得情況下請注意,當單擊搜索欄時,我希望導航欄被向上推.以下解決方案修復了20px間隙問題.
    - (void)viewWillAppear:(BOOL)animated{    [super viewWillAppear:animated];    ...            self.edgesForExtendedLayout = UIRectEdgeTop;    self.searchBar.clipsToBounds = YES;    self.navigationController.navigationBar.translucent = YES;}

    在viewWillDisappear上,半透明屬性需要設置為NO,否則在segue視圖中,控制器導航欄將保持與視圖內容一起推送.

    - (void)viewWillDisappear:(BOOL)animated{    [super viewWillDisappear:animated];    [self resignFirstResponder];    self.navigationController.navigationBar.translucent = NO;}

    希望這可以幫助.

    以上是來客網為你收集整理得ios – UISearchBar到UISearchDisplayController得轉換是20px全部內容,希望內容能夠幫你解決ios – UISearchBar到UISearchDisplayController得轉換是20px所遇到得程序開發問題。

    如果覺得來客網網站內容還不錯,歡迎將來客網網站推薦給程序員好友。

    聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。
    發表評論
    更多 網友評論1 條評論)
    暫無評論

    返回頂部

    主站蜘蛛池模板: 国产无套精品一区二区| 一区二区三区无码高清| 久久精品无码一区二区app| 亚洲视频一区二区三区| 一区二区三区日本电影| 在线视频一区二区三区| 中文字幕精品无码一区二区三区| 亚洲日韩国产一区二区三区在线 | 一区五十路在线中出| 亚洲一区AV无码少妇电影| 色欲综合一区二区三区| 2014AV天堂无码一区| 亚洲国产av一区二区三区| 国产精品无码一区二区三区免费| 亚洲综合在线一区二区三区| 亚洲AV无码一区二区三区DV| 中文人妻av高清一区二区| 亚洲成a人一区二区三区| 国产精品免费视频一区| 日本精品无码一区二区三区久久久| 无码人妻精品一区二区三区66| 东京热无码一区二区三区av| 亚洲毛片不卡av在线播放一区| 日韩精品一区二区三区毛片 | 亚洲欧美国产国产一区二区三区| 午夜DV内射一区二区| 国产在线一区二区综合免费视频| 久久无码一区二区三区少妇| 日韩精品一区二区三区视频| 精品一区二区三区免费毛片| 国产成人一区二区精品非洲| 国产成人精品亚洲一区| 国内精品视频一区二区三区| 亚洲一本一道一区二区三区| 少妇一夜三次一区二区| 精品一区二区久久久久久久网精| 无码aⅴ精品一区二区三区| 精品无码国产一区二区三区麻豆| 日韩高清一区二区三区不卡| 国产伦理一区二区三区| 日韩视频在线观看一区二区|