Edit New issue iPad 搜索样式优化, 不隐藏Navigation #20

This commit is contained in:
life
2015-11-06 09:55:57 +08:00
parent 4f889e637e
commit c1b1cda1a4
6 changed files with 174 additions and 73 deletions

View File

@@ -124,7 +124,7 @@
self.title = NSLocalizedString(@"Notebook", nil);
// , , , search bar,
// , , , search bar,
// http://stackoverflow.com/a/20975075/4269908
[self setAutomaticallyAdjustsScrollViewInsets:YES];
[self setExtendedLayoutIncludesOpaqueBars:YES];
@@ -139,7 +139,8 @@
{
[super viewWillAppear:animated];
if(self.isSelectOnSearch) {
// IPAD, isSelectOnSearch
if(self.isSelectOnSearch && !IS_IPAD) {
NSLog(@"self.isSelectOnSearch viewWillAppear");
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
@@ -791,6 +792,32 @@
return titleLen;
}
// ipadsearch bar, navigation
// ipadnavigationController, SWTableViewCell selectCell
// http://stackoverflow.com/a/5860412/4269908
//- (UINavigationController *)navigationController {
// if (IS_IPAD) {
// return nil;
// } else {
// return self.navigationController;
// }
//}
- (UINavigationController *)navigationController {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1];
// Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"];
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]];
[array removeObject:@""];
// Array[3] == class caller
if([array[3] isEqualToString:@"UISearchDisplayController"]) {
return nil;
}
}
return [super navigationController];
}
#pragma mark - UISearchDisplayDelegate Methods
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
@@ -812,26 +839,30 @@
// , uisearchbar
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
[self setBarStyleBlack];
// cate
if(self.delegate) {
// 1.
if (!IS_IPAD) {
[UIView animateWithDuration:0.25f animations:^{
[self setBarStyleBlack];
// cate
if(self.delegate) {
// 1.
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
self.view.frame = frame;
}];
NSLog(@"setNavigationBarHidden YES!!!!!!!!!");
[self.navigationController setNavigationBarHidden:YES animated:YES];
CGRect frame = self.view.frame;
frame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
frame.size.height = [self.delegate getSearchedViewHeight];
self.view.frame = frame;
}];
NSLog(@"setNavigationBarHidden YES!!!!!!!!!");
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getSearchedViewHeight];
self.view.frame = frame;
}
self.isSelectOnSearch = YES;
self.isSelectOnSearch = YES;
}
}
// ,
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
@@ -840,30 +871,34 @@
self.searchedResultsController = nil;
//
// [controller.searchResultsTableView reloadData]; // , !!
// [controller.searchResultsTableView reloadData]; // , !!
[self.tableView reloadData];
[self restoreBarStyle];
if (IS_IPAD) {
// cate
if(self.delegate) {
// 2.
[self restoreBarStyle];
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.origin.y = 64;
self.view.frame = frame;
} completion:^(BOOL finished) {
if(finished) {
// cate
if(self.delegate) {
// 2.
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getCancelSearchViewHeight];
frame.origin.y = 64;
self.view.frame = frame;
}
}];
} completion:^(BOOL finished) {
if(finished) {
CGRect frame = self.view.frame;
frame.size.height = [self.delegate getCancelSearchViewHeight];
self.view.frame = frame;
}
}];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
self.isSelectOnSearch = NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
self.isSelectOnSearch = NO;
}
#pragma mark - UISearchBarDelegate Methods