Skip to content

Commit

Permalink
Merge pull request #9496 from vijaysingh-axway/TIMOB-25358_6_3_X
Browse files Browse the repository at this point in the history
[TIMOB-25358](6_3_X):iOS Problem with Searchbar, SDK 6.2.0 and later
  • Loading branch information
ewieberappc committed Oct 10, 2017
2 parents 310a542 + c516306 commit 5973fc8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
1 change: 1 addition & 0 deletions iphone/Classes/TiBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ enum {
#define TI_KEYBOARD_PORTRAIT_HEIGHT 216
#define TI_KEYBOARD_LANDSCAPE_HEIGHT 140

#define TI_SEARCHBAR_HEIGHT 56

#ifdef DEBUG
#define FRAME_DEBUG(f) \
Expand Down
27 changes: 18 additions & 9 deletions iphone/Classes/TiUIListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ - (UITableView *)searchTableView
_searchTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
_searchTableView.delegate = self;
_searchTableView.dataSource = self;

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

#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater]) {
Expand Down Expand Up @@ -2129,7 +2135,7 @@ - (void)didDismissSearchController:(UISearchController *)searchController
- (void)presentSearchController:(UISearchController *)controller
{
TiColor *resultsBackgroundColor = [TiUtils colorValue:[[self proxy] valueForKey:@"resultsBackgroundColor"]];
TiColor * resultsSeparatorColor = [TiUtils colorValue:[[self proxy] valueForKey:@"resultsSeparatorColor"]];
TiColor *resultsSeparatorColor = [TiUtils colorValue:[[self proxy] valueForKey:@"resultsSeparatorColor"]];
id resultsSeparatorInsets = [[self proxy] valueForKey:@"resultsSeparatorInsets"];
id resultsSeparatorStyle = [[self proxy] valueForKey:@"resultsSeparatorStyle"];

Expand Down Expand Up @@ -2162,18 +2168,21 @@ - (void)presentSearchController:(UISearchController *)controller
UIViewController *viewController = nil;
if ([proxy isKindOfClass:[TiWindowProxy class]]) {
viewController = [proxy windowHoldingController];
}
else {
} else {
viewController = [[TiApp app] controller];
}
viewController.definesPresentationContext = YES;

[viewController presentViewController:controller animated:NO completion:^{
UIView *view = controller.searchBar.superview;
view.frame = CGRectMake(view.frame.origin.x, self.frame.origin.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);
}];
[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, 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(convertedOrigin.x, convertedOrigin.y + view.frame.size.height, self.frame.size.width, self.frame.size.height);
}];

id searchButtonTitle = [searchViewProxy valueForKey:@"cancelButtonTitle"];
ENSURE_TYPE_OR_NIL(searchButtonTitle, NSString);
Expand Down
22 changes: 14 additions & 8 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,13 @@ - (UITableView *)searchTableView
_searchTableView.delegate = self;
_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];
Expand Down Expand Up @@ -1639,7 +1644,8 @@ -(void)updateSearchView

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 @@ -2843,11 +2849,11 @@ - (void)presentSearchController:(UISearchController *)controller
viewController.definesPresentationContext = YES;

[viewController presentViewController:controller animated:NO completion:^{
UIView *view = controller.searchBar.superview;
view.frame = CGRectMake(view.frame.origin.x, self.frame.origin.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);
CGPoint convertedOrigin = [self.superview convertPoint:self.frame.origin toView:viewController.view];
UIView *view = controller.searchBar.superview;
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(convertedOrigin.x, convertedOrigin.y + view.frame.size.height, self.frame.size.width, self.frame.size.height);
}];
}

Expand Down

0 comments on commit 5973fc8

Please sign in to comment.