UISearchBar 动画问题 [英] UISearchBar animation issue

查看:19
本文介绍了UISearchBar 动画问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIViewController,我想在其中显示带有 serchBar 的 tableview.

I have a UIViewController in which I want to show a tableview with the serchBar.

//viewDidLoad
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,
                                                           0, 
                                                           SCREEN_WIDTH(),
                                                           SCREEN_HEIGHT())
                                                    style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;

[self.view addSubview:_tableView];

// adding uisearch bar
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];

_tableView.tableHeaderView = searchBar;

//
 searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
searchDisplayController.delegate = self;
searchDisplayController.searchResultsDataSource = self;

当我在 uisearch 栏内单击以启动动画并且看起来它有 20px 不需要的偏移时会出现问题.

The issue happens when I click inside the uisearch bar so that the animation starts and it looks like it has a 20px unwanted offset.

推荐答案

提醒任何有类似问题的人.我需要添加这一行来解决问题:

As a reminder for anyone with similar issues. I needed to add this line that fixed things:

self.edgesForExtendedLayout = UIRectEdgeNone;

这篇关于UISearchBar 动画问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆