[英]Prevent UISearchBar from indenting right when tapped
In my viewDidLoad
, I programmatically create a search bar. 在
viewDidLoad
,以编程方式创建搜索栏。 When the search field is tapped, the search bar indents to the right. 轻按搜索字段后,搜索栏会向右缩进。 Why is this happening and how do I prevent it from doing so?
为什么会发生这种情况,如何防止这种情况发生? I am not using autolayout.
我没有使用自动版式。
- (void)createSearchBar {
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.delegate = self;
[self.searchController.searchBar sizeToFit];
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.definesPresentationContext = YES;
self.edgesForExtendedLayout = UIRectEdgeNone;
}
您可以尝试使用positionAdjustmentForSearchBarIcon:
或setPositionAdjustment:forSearchBarIcon:
委托调用中对搜索setPositionAdjustment:forSearchBarIcon:
消息调用: searchBarTextDidBeginEditing:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.