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 條評論)
    暫無評論

    返回頂部

    主站蜘蛛池模板: 精品不卡一区中文字幕| 免费无码AV一区二区| 国产一区二区三区美女| 国产成人精品一区二区三区无码| 色欲AV蜜臀一区二区三区| 日韩A无码AV一区二区三区| 国产精品一区二区不卡| 成人精品视频一区二区三区 | 波多野结衣一区二区三区高清av| 人妻少妇精品视频一区二区三区 | 怡红院AV一区二区三区| 亚洲A∨无码一区二区三区| 国产精品 一区 在线| 国产人妖在线观看一区二区| 性色AV一区二区三区天美传媒| 亚洲视频一区网站| 人妻少妇久久中文字幕一区二区| 国精产品一区二区三区糖心| 亚洲福利精品一区二区三区| 精品一区中文字幕| 国产主播福利精品一区二区| 成人免费一区二区三区在线观看| 亚洲精品精华液一区二区| 精品爆乳一区二区三区无码av| 国产电影一区二区| 女女同性一区二区三区四区| 大帝AV在线一区二区三区| 精品国产一区二区三区香蕉事| 尤物精品视频一区二区三区| 精品无码中出一区二区| 亚洲性日韩精品一区二区三区| 变态调教一区二区三区| 精品一区二区三区色花堂| 免费观看一区二区三区| 无码人妻精品一区二区| 亚洲一区二区三区在线网站 | 无码毛片一区二区三区中文字幕| 麻豆精品一区二区综合av| 大屁股熟女一区二区三区| 一区二区免费视频| 国产小仙女视频一区二区三区|