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-15282] Setup searchBar heirarchy only when required #4717

Merged
merged 2 commits into from
Sep 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 4 additions & 11 deletions iphone/Classes/TiUIListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ - (UITableView *)tableView

-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
{
if (![searchController isActive]) {
[searchViewProxy ensureSearchBarHeirarchy];
}
[super frameSizeChanged:frame bounds:bounds];

if (_headerViewProxy != nil) {
Expand Down Expand Up @@ -1442,20 +1445,10 @@ - (void) searchDisplayControllerDidEndSearch:(UISearchDisplayController *)contro
}
//IOS7 DP3. TableView seems to be adding the searchView to
//tableView. Bug on IOS7?
if ([TiUtils isIOS7OrGreater]) {
if (![[[controller searchBar] superview] isKindOfClass:[TiUIView class]]) {
if ([[searchViewProxy view] respondsToSelector:@selector(searchBar)]) {
[[searchViewProxy view] performSelector:@selector(searchBar)];
} else {
[_headerViewProxy layoutChildren:NO];
}
}
}
[searchViewProxy ensureSearchBarHeirarchy];
[_tableView reloadData];
}



#pragma mark - TiScrolling

-(void)keyboardDidShowAtHeight:(CGFloat)keyboardTop
Expand Down
5 changes: 0 additions & 5 deletions iphone/Classes/TiUISearchBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ -(UISearchBar*)searchBar
[searchView setDelegate:self];
[searchView setShowsCancelButton:[(TiUISearchBarProxy *)[self proxy] showsCancelButton]];
}
//IOS7 DP3 bug fix. See searchcontroller delegate method in listView.
if ([searchView superview] != self) {
[self addSubview:searchView];
[searchView setFrame:[self bounds]];
}
return searchView;
}

Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUISearchBarProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
// but is internal ONLY, and should NOT be used by javascript.
@property(nonatomic,readwrite,assign) BOOL showsCancelButton;

#pragma mark - Titanium Internal Use
-(void)ensureSearchBarHeirarchy;
@end

#endif
14 changes: 14 additions & 0 deletions iphone/Classes/TiUISearchBarProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ -(UISearchBar*)searchBar
return [(TiUISearchBar*)[self view] searchBar];
}

-(void)ensureSearchBarHeirarchy
{
WARN_IF_BACKGROUND_THREAD;
if ([self viewAttached]) {
UISearchBar* searchBar = [self searchBar];
if ([searchBar superview] != view) {
[view addSubview:searchBar];
[searchBar setFrame:[view bounds]];
}
}

}


-(NSMutableDictionary*)langConversionTable
{
return [NSMutableDictionary dictionaryWithObjectsAndKeys:@"prompt",@"promptid",@"hintText",@"hinttextid",nil];
Expand Down
15 changes: 8 additions & 7 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,10 @@ -(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
[tableview setContentOffset:CGPointMake(0,0)];
}
}

if (!searchActivated) {
[searchField ensureSearchBarHeirarchy];
}

[super frameSizeChanged:frame bounds:bounds];

Expand Down Expand Up @@ -1442,6 +1446,9 @@ -(void)updateSearchView
{
CGRect wrapperFrame = CGRectMake(0, 0, [tableview bounds].size.width, TI_NAVBAR_HEIGHT);
tableHeaderView = [[UIView alloc] initWithFrame:wrapperFrame];
[tableHeaderView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[searchView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[[searchField searchBar] setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[TiUtils setView:searchView positionRect:wrapperFrame];
[tableHeaderView addSubview:searchView];
[tableview setTableHeaderView:tableHeaderView];
Expand Down Expand Up @@ -2523,13 +2530,7 @@ - (void) searchDisplayControllerDidEndSearch:(UISearchDisplayController *)contro

//IOS7 DP3. TableView seems to be adding the searchView to
//tableView. Bug on IOS7?
if ([TiUtils isIOS7OrGreater]) {
if (![[[controller searchBar] superview] isKindOfClass:[TiUIView class]]) {
if ([[searchField view] respondsToSelector:@selector(searchBar)]) {
[[searchField view] performSelector:@selector(searchBar)];
}
}
}
[searchField ensureSearchBarHeirarchy];
animateHide = YES;
[self performSelector:@selector(hideSearchScreen:) withObject:nil afterDelay:0.2];
}
Expand Down