简体   繁体   English

通过用户触摸在iPhone应用程序中显示/隐藏工具栏

[英]Show/Hide Toolbars in iPhone app on user touch

How can I make the main content view of my app full screen, and show the toolbar only when the user touches the screen and one more touch will hide the toolbar? 如何使应用程序的主要内容视图全屏显示,并且仅在用户触摸屏幕时显示工具栏,再触摸一次就会隐藏工具栏? kind of like the ibooks app? 有点像ibooks应用?

also how do I make a toolbar transparent? 还如何使工具栏透明?

To make content view of your app full screen just set [[UIApplication sharedApplication] setStatusBarHidden:YES]; 要使您的应用程序的内容视图全屏显示,只需设置[[UIApplication sharedApplication] setStatusBarHidden:YES];

To hide/show : Identify the tap area of status bar when clicked set - [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES]; 隐藏/显示:单击时确定状态栏的点击区域set- [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES]; .

To make it transparent use [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent]; 要使其透明,请使用[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

Out of interest, are you using a UIWebView ? 出于兴趣,您正在使用UIWebView吗? Because that makes life more tricky, because you need to detect tap views to the UIWebView . 因为这会使生活变得更加棘手,因为您需要检测UIWebView点击视图。 There are four main ways of doing this. 有四种主要方法可以做到这一点。

  1. Subclass UIWebView . 子类UIWebView Not recommended because Apple tell you not to do this. 不建议使用,因为Apple告诉您不要这样做。
  2. Subclass UIWindow . 子类UIWindow I found this to work very well - until I needed to rotate to landscape, which it wouldn't let me do! 我发现这非常有效-直到我需要旋转到风景为止,这不允许我这样做! I'm still trying to find a solution to this. 我仍在努力寻找解决方案。 In any case, see http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/ . 无论如何,请参见http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/
  3. Something about putting a transparent UIView on top of the UIWebView , but I think this also involves subclassing and is not recommended. 关于将透明的UIView放在UIWebView之上的东西,但是我认为这也涉及子类化,因此不建议这样做。 I have never tried this. 我从来没有尝试过。
  4. Use a slightly hacky Javascript detection through the webpage to send messages to the UIWebView (through changing document.location in the javascript, then intercepting the URL request through the Objective-C code, denying access, and using it to do the things which Chandan Shetty SP suggests above. 在网页上使用略有漏洞的Javascript检测将消息发送到UIWebView (通过更改javascript中的document.location ,然后通过Objective-C代码拦截URL请求,拒绝访问,并使用它来完成Chandan Shetty的工作SP以上建议。

However, if you are not using a UIWebView , this post is irrelevant. 但是,如果您不使用UIWebView ,则此帖子无关紧要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM