2010-09-27 56 views
0

我想根据光标位置来隐藏导航栏,所以我可以使用iPhone的全屏。但我不知道如何开始它。如何根据光标位置隐藏导航栏来使用全屏?

类似(减少混乱:))问题:Show/hide UIToolbar, "match finger movement", precisely as in for example iOS7 Safari

+0

什么是鼠标操作? – jer 2010-09-27 04:34:44

+0

地狱在哪里?您正在为iPhone工作,而不是为机器工作。 – 2010-09-27 04:49:55

+0

喜欢光标移动到它应该显示的导航栏上,当光标移动到屏幕上时,导航栏应该是不可见的 – iphoneStruggler 2010-09-27 04:49:56

回答

1

使用下面的代码,如果你想隐藏和取消隐藏在双击导航栏上的视图的任何部分

在您的.h文件中:

IBOutlet UINavigationController *navigationController; 

将IBOutlet连接到您的XIB中。

在.m文件:

-(void)viewDidLoad { 

    [super viewDidLoad]; 

    [navigationController setNavigationBarHidden:YES]; 



} 

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; 

    if (touch.tapCount == 2) { 

     [navigationController setNavigationBarHidden:NO]; 
     [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(hideBar) userInfo:nil repeats:NO]; 


     } 

    } 

-(void)hidebar{ 

[navigationController setNavigationBarHidden:YES]; 



} 

做修改,按照您的要求。

快乐编码!

+0

thanks.i将工作。 – iphoneStruggler 2010-09-27 05:34:33

+0

wlcome。获得投票是最好的谢谢。 :P – 2010-09-27 08:30:29

0

iPhone上没有光标,但是你的意思是你想做类似safari的操作 - 在向下滚动多个屏幕页面时隐藏地址栏?

假设你正在使用的UITableView,我有一个解决方案: 1.我们已经知道每个表行的高度 - > cell.frame.size.heigh 2,我们已经知道了屏幕的高度 - > view.bounds.size.height 3.每当它生成一个单元格时,UITableView调用cellForRowAtIndexPath 因此,只要您看到属于同一行的行索引,就可以轻松地知道表格,行索引和总高度有多少个单元格到下一个屏幕页面,您应该使用动画隐藏导航栏。否则,如果所有行索引都属于第一屏幕 - >用动画显示导航栏。