Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25358]:iOS Problem with Searchbar, SDK 6.2.0 and later #9495

Merged
merged 17 commits into from
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions iphone/Classes/TiBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ enum {
#define TI_KEYBOARD_PORTRAIT_HEIGHT 216
#define TI_KEYBOARD_LANDSCAPE_HEIGHT 140

#define TI_SEARCHBAR_HEIGHT 56

#ifdef DEBUG
#define FRAME_DEBUG(f) \
NSLog(@"FRAME -- size=%fx%f, origin=%f,%f", f.size.width, f.size.height, f.origin.x, f.origin.y);
Expand Down
12 changes: 10 additions & 2 deletions iphone/Classes/TiUIListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ - (UITableView *)searchTableView
_searchTableView.delegate = self;
_searchTableView.dataSource = self;

#if IS_XCODE_9
if ([TiUtils isIOS11OrGreater]) {
_searchTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
#endif

#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater]) {
_searchTableView.prefetchDataSource = self;
Expand Down Expand Up @@ -2154,10 +2160,12 @@ - (void)presentSearchController:(UISearchController *)controller
[viewController presentViewController:controller
animated:NO
completion:^{
CGPoint convertedOrigin = [self.superview convertPoint:self.frame.origin toView:viewController.view];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, so the proposal worked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)


UIView *view = controller.searchBar.superview;
view.frame = CGRectMake(view.frame.origin.x, self.frame.origin.y, view.frame.size.width, view.frame.size.height);
view.frame = CGRectMake(view.frame.origin.x, convertedOrigin.y, view.frame.size.width, view.frame.size.height);
controller.searchBar.frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height);
resultViewController.tableView.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y + view.frame.size.height, self.frame.size.width, self.frame.size.height);
resultViewController.tableView.frame = CGRectMake(convertedOrigin.x, convertedOrigin.y + view.frame.size.height, self.frame.size.width, self.frame.size.height);
}];

id searchButtonTitle = [searchViewProxy valueForKey:@"cancelButtonTitle"];
Expand Down
16 changes: 12 additions & 4 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ - (UITableView *)searchTableView
_searchTableView.dataSource = self;
_searchTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

#if IS_XCODE_9
if ([TiUtils isIOS11OrGreater]) {
_searchTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
#endif

if (TiDimensionIsDip(rowHeight)) {
[_searchTableView setRowHeight:rowHeight.value];
} else {
Expand Down Expand Up @@ -1534,7 +1540,8 @@ - (void)updateSearchView
UIView *searchView = [searchField view];

if (tableHeaderView == nil) {
CGRect wrapperFrame = CGRectMake(0, 0, [tableview bounds].size.width, TI_NAVBAR_HEIGHT);
CGFloat wrapperHeight = [TiUtils isIOS11OrGreater] ? TI_SEARCHBAR_HEIGHT : TI_NAVBAR_HEIGHT;
CGRect wrapperFrame = CGRectMake(0, 0, [tableview bounds].size.width, wrapperHeight);
tableHeaderView = [[UIView alloc] initWithFrame:wrapperFrame];
[tableHeaderView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[searchView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
Expand Down Expand Up @@ -2667,11 +2674,12 @@ - (void)presentSearchController:(UISearchController *)controller
[viewController presentViewController:controller
animated:NO
completion:^{
CGPoint convertedOrigin = [self.superview convertPoint:self.frame.origin toView:viewController.view];

UIView *view = controller.searchBar.superview;
view.frame = CGRectMake(view.frame.origin.x, self.frame.origin.y, view.frame.size.width, view.frame.size.height);
view.frame = CGRectMake(view.frame.origin.x, convertedOrigin.y, view.frame.size.width, view.frame.size.height);
controller.searchBar.frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height);
resultViewController.tableView.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y + view.frame.size.height, self.frame.size.width, self.frame.size.height);

resultViewController.tableView.frame = CGRectMake(convertedOrigin.x, convertedOrigin.y + view.frame.size.height, self.frame.size.width, self.frame.size.height);
}];
}

Expand Down