mirror of
https://github.com/leanote/leanote-ios.git
synced 2025-10-16 16:14:10 +00:00
Edit New issue iPad 搜索样式优化, 不隐藏Navigation #20
This commit is contained in:
@@ -108,7 +108,7 @@ NSString const *key = @"isSelectOnSearchKey";
|
||||
|
||||
-(void)setBarStyle
|
||||
{
|
||||
if(self.isSelectOnSearch) {
|
||||
if(self.isSelectOnSearch && !IS_IPAD) {
|
||||
[self setBarStyleBlack];
|
||||
}
|
||||
else {
|
||||
|
@@ -846,13 +846,38 @@
|
||||
return titleLen;
|
||||
}
|
||||
|
||||
// 搜索
|
||||
// ipad下search bar上移, 但navigation却不隐藏
|
||||
// ipad下模拟没有navigationController, 但是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
|
||||
|
||||
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
|
||||
{
|
||||
NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
||||
// NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
||||
|
||||
NSString *searchPredicate = [NSString stringWithFormat:@"title contains[cd] '%@' or content contains[cd] '%@'", searchString, searchString];
|
||||
|
||||
@@ -868,8 +893,10 @@
|
||||
|
||||
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
|
||||
{
|
||||
[self setBarStyleBlack];
|
||||
self.isSelectOnSearch = YES;
|
||||
if (!IS_IPAD) {
|
||||
[self setBarStyleBlack];
|
||||
self.isSelectOnSearch = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
|
||||
@@ -881,9 +908,11 @@
|
||||
|
||||
// 为什么要reload ?
|
||||
// [self.tableView reloadData];
|
||||
if (!IS_IPAD) {
|
||||
[self restoreBarStyle];
|
||||
|
||||
[self restoreBarStyle];
|
||||
self.isSelectOnSearch = NO;
|
||||
self.isSelectOnSearch = NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UISearchBarDelegate Methods
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
// ipad下search bar上移, 但navigation却不隐藏
|
||||
// ipad下模拟没有navigationController, 但是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];
|
||||
if (!IS_IPAD) {
|
||||
|
||||
// cate
|
||||
if(self.delegate) {
|
||||
// 1. 这里控制动画
|
||||
[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];
|
||||
|
||||
[UIView animateWithDuration:0.25f animations:^{
|
||||
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];
|
||||
}
|
||||
|
||||
self.isSelectOnSearch = YES;
|
||||
|
||||
CGRect frame = self.view.frame;
|
||||
frame.size.height = [self.delegate getSearchedViewHeight];
|
||||
self.view.frame = frame;
|
||||
}
|
||||
|
||||
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
|
||||
|
@@ -127,7 +127,8 @@
|
||||
[self beautifySearchBar];
|
||||
[self setBarStyle];
|
||||
|
||||
if(self.isSelectOnSearch) {
|
||||
// 非IPAD下, 如果当前是isSelectOnSearch才要隐藏
|
||||
if(self.isSelectOnSearch && !IS_IPAD) {
|
||||
NSLog(@"self.isSelectOnSearch viewWillAppear");
|
||||
[self.navigationController setNavigationBarHidden:YES animated:animated];
|
||||
}
|
||||
@@ -671,6 +672,32 @@
|
||||
return titleLen;
|
||||
}
|
||||
|
||||
// ipad下search bar上移, 但navigation却不隐藏
|
||||
// ipad下模拟没有navigationController, 但是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
|
||||
|
||||
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
|
||||
@@ -687,56 +714,64 @@
|
||||
|
||||
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
|
||||
{
|
||||
[self setBarStyleBlack];
|
||||
// cate
|
||||
if(self.delegate) {
|
||||
// 1. 这里控制动画
|
||||
if (!IS_IPAD) {
|
||||
|
||||
[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;
|
||||
}];
|
||||
|
||||
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
||||
|
||||
[UIView animateWithDuration:0.25f animations:^{
|
||||
CGRect frame = self.view.frame;
|
||||
frame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
|
||||
frame.size.height = [self.delegate getSearchedViewHeight];
|
||||
self.view.frame = frame;
|
||||
}];
|
||||
}
|
||||
self.isSelectOnSearch = 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;
|
||||
}
|
||||
|
||||
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
|
||||
{
|
||||
NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
||||
// NSLog(@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
||||
self.searchedResultsController.delegate = nil;
|
||||
self.searchedResultsController = nil;
|
||||
|
||||
[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
|
||||
|
@@ -194,7 +194,7 @@
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="sectionIndexColor" red="0.031372550870000002" green="0.011764707040000001" blue="0.0078431377190000002" alpha="1" colorSpace="deviceRGB"/>
|
||||
<color key="sectionIndexTrackingBackgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
|
||||
<searchBar key="tableHeaderView" contentMode="redraw" placeholder="Search Note" translucent="NO" id="wUi-Dr-T3x">
|
||||
<searchBar key="tableHeaderView" contentMode="redraw" text="" placeholder="Search Note" translucent="NO" id="wUi-Dr-T3x">
|
||||
<rect key="frame" x="0.0" y="64" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
|
@@ -14,6 +14,8 @@
|
||||
{
|
||||
[super setActive: visible animated: animated];
|
||||
|
||||
// [self.searchContentsController.navigationController setNavigationBarHidden: NO animated: NO];
|
||||
|
||||
/*
|
||||
[self.searchContentsController.navigationController setNavigationBarHidden: NO animated: NO];
|
||||
|
||||
|
Reference in New Issue
Block a user