一区二区日本_久久久久久久国产精品_无码国模国产在线观看_久久99深爱久久99精品_亚洲一区二区三区四区五区午夜_日本在线观看一区二区

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

返回頂部

主站蜘蛛池模板: 国产精品一区二区在线 | 亚洲国产成人精品在线 | 国产99视频精品免费视频7 | 欧美成人h版在线观看 | 人人干人人舔 | 国产九九精品 | 日韩欧美一级片 | 91精品国产91久久久久久吃药 | 欧美日韩不卡合集视频 | 国产a级黄色录像 | 久久综合久久久 | 无码一区二区三区视频 | 武道仙尊动漫在线观看 | 久久久久久久久久久久久9999 | av网站在线播放 | 九九九国产 | 在线欧美一区 | 欧洲视频一区二区 | 三级国产三级在线 | 夜夜爽99久久国产综合精品女不卡 | 色偷偷噜噜噜亚洲男人 | 做a网站| 特一级黄色毛片 | 欧美a级成人淫片免费看 | 日本一区二区不卡 | 中文字幕免费 | 久久婷婷色 | 精品日韩一区 | 日本中文在线视频 | 五月综合激情婷婷 | 日p视频免费看 | 毛片在线看看 | 久久九九免费 | 91中文字幕在线观看 | 国产在线精品一区二区三区 | 日韩电影中文字幕 | 91中文视频 | 国产一区久久精品 | 成人国产在线视频 | 久久综合成人精品亚洲另类欧美 | 亚洲精品久久区二区三区蜜桃臀 |