繁体   English   中英

防止点击时UISearchBar缩进

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM