多个UITableView 或者Scrollview 置顶问题
来源:互联网 发布:南方大数据300a怎么样 编辑:程序博客网 时间:2024/06/05 00:51
UITableView.scrollsToTop =YES; 或者 UIScrollView.scrollsToTop = YES;
如果页面只有单个,或者固定个数的scrollview或者tableView 设置 scrollsToTop 是最便利的方法(只有一个view.scrollsToTop YES 属性,其余的都必须为NO)。
然而如果是不定个数的呢?
这是我在stackoverflow 上找到的一个方法:http://stackoverflow.com/questions/3753097/how-to-detect-touches-in-status-bar
Declare notification name somewhere (e.g. AppDelegate.h):
static NSString * const kStatusBarTappedNotification = @"statusBarTappedNotification";
Add following lines to your AppDelegate.m:
#pragma mark - Status bar touch tracking- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; CGPoint location = [[[event allTouches] anyObject] locationInView:[self window]]; CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; if (CGRectContainsPoint(statusBarFrame, location)) { [self statusBarTouchedAction]; }}- (void)statusBarTouchedAction { [[NSNotificationCenter defaultCenter] postNotificationName:kStatusBarTappedNotification object:nil];}
Observe notification in the needed controller (e.g. in viewWillAppear):
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarTappedAction:) name:kStatusBarTappedNotification object:nil];
Remove observer properly (e.g. in viewDidDisappear):
[[NSNotificationCenter defaultCenter] removeObserver:self name:kStatusBarTappedNotification object:nil];
Implement notification-handling callback:
- (void)statusBarTappedAction:(NSNotification*)notification { NSLog(@"StatusBar tapped"); //handle StatusBar tap here.}
Hope it will help.
0 0
- 多个UITableView 或者Scrollview 置顶问题
- 解决多个listview或者gridview与scrollview滚动条冲突的问题
- ScrollView中嵌套ListView置顶问题
- Scrollview 嵌套listview无法置顶问题
- scrollview初始位置不是置顶的问题
- ScrollView中嵌套ListView置顶问题
- Android-scrollview嵌套listview、webview、gridview不置顶问题
- ScrollView嵌套Gridview或者listview滚动问题
- Scrollview嵌套Listview 或者gridview 焦点问题
- 多个ScrollView或者Listview多级联动效果!!拒绝 直接使用 ScrollTo ScrollBy,使listview、scrollView滚动
- [置顶]iOSDay29之UITableView
- ScrollView 置顶效果
- ScrollView置顶按钮
- ScrollView 初始化位置置顶
- scrollview不置顶
- 跳转到嵌有scrollview的页面,scrollview初始位置不是置顶的问题
- 跳转到嵌有scrollview的页面,scrollview初始位置不是置顶的问题
- android 跳转到嵌有scrollview的页面,scrollview初始位置不是置顶的问题
- LINUX入侵检测指导
- 做点Postgresql笔记
- 题目96 n-1位数
- 基于STM32和W5500的Modbus TCP通讯
- I/O多路转接之select
- 多个UITableView 或者Scrollview 置顶问题
- 机器学习面试问题6
- leetcode 215. Kth Largest Element in an Array
- 三维空间两直线/线段最短距离、线段计算算法
- 源码实现ArrayList的常用方法
- 用websocket爬去来疯的实时聊天数据
- EasyDarwin开源流媒体云平台VS调试断点提示“还没有为该文档加载任何符号”的解决办法
- 定时向文件写内容
- git-remote-https.exe-无法找到入口