Reputation: 488
In my viewDidLoad
, I programmatically create a search bar. 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;
}
Upvotes: 0
Views: 205
Reputation: 132
you can try using the positionAdjustmentForSearchBarIcon:
or setPositionAdjustment:forSearchBarIcon:
message calls to the searchbar inside the delegate call:searchBarTextDidBeginEditing:
Upvotes: 0