![](/img/trans.png)
[英]UISearchBar in UISearchController slips to the right when tapped
[英]Prevent UISearchBar from indenting right when tapped
在viewDidLoad
,以编程方式创建搜索栏。 轻按搜索字段后,搜索栏会向右缩进。 为什么会发生这种情况,如何防止这种情况发生? 我没有使用自动版式。
- (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.