Disabling the Personal hotspot notification - ios

Enabling personal hot spot pushing down the view and related subviews pushing down. How to disable the personal hotspot notification programmatically? (how can i restrict iPhone status bar to original size even when HOT SPOT is on?)

I found rather late that the Personal Hotspot doesn't just add 20points to the status bar, it messes up views that rely on drop points in an animator with gravity. I added code that checks the status bar height before laying out the views. If it's not 20, then it's probably the hotspot, so I just hide the status bar. Not an ideal solution, but works so far.
- (BOOL)prefersStatusBarHidden {
if ([UIApplication sharedApplication].statusBarFrame.size.height == 20) {
NSLog(#"Status bar is 20 so returning NO for hidden");
return NO;
}
NSLog(#"Status bar is not 20 so returning YES for hidden");
return YES;
}

If you disable statusbar then automatically disable Hotspot bar.

The Apple documentation is not very descriptive of the status bar, esp. the 2nd row that appears when you are using hotspot, map, calls, etc.
Even if more than one is running, there is only one additional row.
I don't know how 3rd party apps appear, but the questioner asked specifically about Personal Hotspot which is a system service.
I doubt the display can be controlled by anybody, except when the user turns the service off.
You probably have to do it the "hard" way". You should hide the main status bar, then draw your own custom status bar.
BTW, Apple says not to do this:
Use the system-provided status bar. People expect the status bar to be consistent systemwide. Don’t replace it with a custom status bar.
https://developer.apple.com/ios/human-interface-guidelines/bars/status-bars/

It's an alternative way but it works.
First include a new key in your project's Info.plist:
Status bar is initially hidden: YES
And then, in your AppDelegate, at didFinishLaunchingWithOptions you can set:
[application setStatusBarHidden:NO];
This will hide the hotspot bar during launch screen and then show it again when the app launches.

Related

Why does my status bar disappear after a couple of seconds Xcode?

When I run my app on simulator or device, my status bar (time, battery, service) is visible for about 2 seconds during the launch screen and then disappears and doesn't come back.
I have tried many variations within the info.plist file, changing View controller-based status bar appearance to YES and NO. trying different Status bar style and Status bar is initially hidden combinations. I don't know where i am going wrong.
EDIT:
I have rebuilt the whole app as a trouble shoot but it does the exact same thing still. Does anyone know what else I can try? I have spent two days searching for answers.
Can someone please help me?
I found the answer. I changed the IOS_IS_WINDOWED variable in my main.m file from False to True :)
putenv("IOS_IS_WINDOWED=True");

How to get rid of the status bar background on the UIWebView?

Since iOS 11, when the UIWebView is full screen, a fake background appears on the status bar with the same color of the UIWebView background.
Anyone knows how to get rid of it?
Even adding the IUWebView to a storyboard and make it full screen will make the status bar background to appear
I've been trying to edit the size and some other properties of the UIWebView and none of them worked, but it's definitely something from the UIWebView.
Also tried to see all the subviews and it's sizes and didn't see anything strange.
Attached a screenshot, see the grey "statusbar", it disappears when scrolling, and doesn't appear if the UIWebView is not over that part of the screen.
I want it as on the second screenshot, only remove the fake background, not the status bar.
This happens because of UIScrollView new behavior to adjust the content inset to include safe area insets like the status bar.
To fix it, just set it to UIScrollViewContentInsetAdjustmentNever
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
Since iOS 11 Beta 4 you can add this to your viewport and will also remove the fake statusbar
viewport-fit=cover
To do this entirely in HTML/CSS, viewport-fit=cover in the Viewport meta tag is the correct way to handle this.
But you'll also want to adjust your padding dynamically to handle the differently sized status bar on iPhone X with its notched camera/speaker.
Luckily, Apple exposed some CSS constants for the safe area insets, so you can take advantage of those in your CSS:
i.e., padding-top: constant(safe-area-inset-top);
I wrote a bit more about this scenario and the new features for iOS 11 and iPhone X: https://ayogo.com/blog/ios11-viewport/
Swift version:
webView.scrollView.contentInsetAdjustmentBehavior = .never

Cordova Hide Status Bar

I'm building an application for iPad with Phonegap and Framework7 and I can't seem to get the status bar to be hidden on the iPad no matter what I do.
I've tried to google out a few tutorials, including the following questions:
How to remove iOS status bar with Phonegap Build?
How to completely hide the status bar in iOS using Cordova?
Cordova/Phonegap ignores fullscreen preference in config.xml on iOS
I've tried the solutions provided in all the answers of the questions above and my status bar is still there.
I've opened the project with xCode and I can see that the settings are configured fine:
For the iPhone settings in deployment info:
Status Bar Style: Default
Hide status bar (checked)
Requires full screen (checked)
For the iPad settings in deployment info:
Hide during application launch (checked)
Requires full screen (checked)
In the Info > Custom iOS Target Properties, I have set the following:
View controller-based status bar appearance: NO
I've also tried to use the JavaScript way when the deviceready event has been fired:
StatusBar.hide();
Update
When I run:
StatusBar.isVisible
The property returns false, however I still see the white bar at the top.
After some long hours of debugging, I finally figured out what the issue was.
In fact, the status bar was hidden, and the white bar we would see is the overlay provided by Framework7, which explains the following:
StatusBar.isVisible // false
Apparently Framework7 is hiding the status bar, but leaving a blank white bar on top of the application, which is a padding.
So to remove the bar, I had to remove the class with-statusbar-overlay from the html tag. And to do so, I added the following to my Javascript file:
document.documentElement.classList.remove('with-statusbar-overlay');
Note that the Javascript fix must be executed before the deviceready event. Otherwise, you will see the home view with the bar, then the bar will disappear. If you put it before the event, the user will never see the bar.
document.documentElement.classList.remove('with-statusbar-overlay');
Dom7(document).on('deviceready', function(){
// Your code
});

Removing unnecessary titles and icons at the top of iOS Simulators

I'm new to iOS and my question will seem little bit confusing to you but it make sense I'm working on a project where I have to use a custom NavigationBar while I was working on that I saw these icons and title at the top
and as the requirement of my project I need a Bar like this
and you can see the word slightly overriding my button (the red bar is not a part of my button). so my question is, is there any way we can remove these buttons from our simulator because I noticed when i click on the back button sometimes it'll not work due the fact I was clicking on the that "Carrier" title. Soo is there anyone who knows something about it and please don't suggest me to resize the button or something like that it's not my point if you understand.
As Nobody have Answered it yet let me tell you the answer that I find working:-
To hide status bar in iOS7 you need 2 lines of code
in application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions write
[[UIApplication sharedApplication] setStatusBarHidden:YES];
in info.plist add this
View-Controller Based Status Bar Appearance = NO

iPhone app in landscape mode, 2008 systems

Please note that this question is from 2008 and now is of only historic interest.
What's the best way to create an iPhone application that runs in landscape mode from the start, regardless of the position of the device?
Both programmatically and using the Interface Builder.
Historic answer only. Spectacularly out of date.
Please note that this answer is now hugely out of date/
This answer is only a historical curiosity.
Exciting news! As discovered by Andrew below, this problem has been fixed by Apple in 4.0+.
It would appear it is NO longer necessary to force the size of the view on every view, and the specific serious problem of landscape "only working the first time" has been resolved.
As of April 2011, it is not possible to test or even build anything below 4.0, so the question is purely a historic curiosity. It's incredible how much trouble it caused developers for so long!
Here is the original discussion and solution. This is utterly irrelevant now, as these systems are not even operable.
It is EXTREMELY DIFFICULT to make this work fully -- there are at least three problems/bugs at play.
try this .. interface builder landscape design
Note in particular that where it says "and you need to use shouldAutorotateToInterfaceOrientation properly everywhere" it means everywhere, all your fullscreen views.
Hope it helps in this nightmare!
An important reminder of the ADDITIONAL well-known problem at hand here: if you are trying to swap between MORE THAN ONE view (all landscape), IT SIMPLY DOES NOT WORK. It is essential to remember this or you will waste days on the problem. It is literally NOT POSSIBLE. It is the biggest open, known, bug on the iOS platform. There is literally no way to make the hardware make the second view you load, be landscape. The annoying but simple workaround, and what you must do, is have a trivial master UIViewController that does nothing but sit there and let you swap between your views.
In other words, in iOS because of a major know bug:
[window addSubview:happyThing.view];
[window makeKeyAndVisible];
You can do that only once. Later, if you try to remove happyThing.view, and instead put in there newThing.view, IT DOES NOT WORK - AND THAT'S THAT. The machine will never rotate the view to landscape. There is no trick fix, even Apple cannot make it work. The workaround you must adopt is having an overall UIViewController that simply sits there and just holds your various views (happyThing, newThing, etc). Hope it helps!
From the Apple Dev Site:
To start your application in landscape
mode so that the status bar is in the
appropriate position immediately, edit
your Info.plist file to add the
UIInterfaceOrientation key with the
appropriate value
(UIInterfaceOrientationLandscapeRight
or
UIInterfaceOrientationLandscapeLeft),
as shown in Listing 2.
Listing 2: Starting your application
in landscape mode
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
Summary and integration from all the posts, after testing it myself; check the update for 4.x, 5.x below.
As of 3.2 you cannot change the orientation of a running application from code.
But you can start an application with a fixed orientation, although doing so this is not straightforward.
Try with this recipe:
set your orientation to UISupportedInterfaceOrientations in the Info.plist file
in your window define a 480x320 "base view controller". Every other view will be added as a subview to its view.
in all view controllers set up the shouldAutorotateToInterfaceOrientation: method (to return the same value you defined in the plist, of course)
in all view controllers set a background view with
self.view.frame = CGRectMake(0, 0, 480, 320)
in the viewDidLoad method.
Update (iOS 4.x, 5.x): the Apple iOS App Programming Guide has a "Launching in Landscape Mode" paragraph in the "Advanced App Tricks" chapter.
References:
interface builder landscape design
interface builder landscape design-1
First I set in info.plist
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
then I put this code in applicationDidFinishLaunching:
CGAffineTransform rotate = CGAffineTransformMakeRotation(1.57079633);
[window setTransform:rotate];
CGRect contentRect = CGRectMake(0, 0, 480, 320);
window.bounds = contentRect;
[window setCenter:CGPointMake(160.0f, 240.0f)];
This way I can work on the view in Interface Builder in landscape mode.
sasb's and michaelpryor's answer appears to be correct, but if it's not working for you, try this alternative:
- (void)applicationDidFinishLaunchingUIApplication *)application {
application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
}
Or this one:
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
Or this one:
[application setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:NO];
You may also have to call window makeKeyAndVisible; first.
A few links: Developing in landscape mode, iPhone SDK: How to force Landscape mode only?
#Robert: please refer to The iPhone SDK, NDA, and Stack Overflow.
I'm surprised no one has come up with this answer yet:
In all my tests when a dismissing a modal view controller the parent view controller's preferred orientation set in shouldAutorotateToInterfaceOrientation is honored even when part of a UINavigationController. So the solution to this is simple:
Create a dummy UIViewController with a UIImageView for a background. Set the image to the default.png image your app uses on startup.
When viewWillAppear gets called in your root view controller, just present the dummy view controller without animation.
when viewDidAppear gets called in your dummy view controller, dismiss the view controller with a nice cross dissolve animation.
Not only does this work, but it looks good! BTW, just for clarification i do the root view controller's viewWillAppear like this:
- (void)viewWillAppear:(BOOL)animated
{
if ( dummy != nil ) {
[dummy setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:dummy animated:NO];
[dummy release];
dummy = nil;
}
...
}
The latest iPhone OS Programming Guide has a full section on this, with sample code. I am sure this is a recent addition, so maybe you missed it. It explains all the conditions you have to comply with; basically...
set the Info.plist properties (this changes the position of the status bar, but not the view)
rotate your view manually around its center, on either your UIViewController viewDidLoad: method or your applicationDidFinishLaunching: method or implement auto rotation ("Autoresizing behaviors", page 124)
Look for "Launching in Landscape Mode", page 102.
See this answer: Landscape Mode ONLY for iPhone or iPad
add orientation to plist
shouldAutorotateToInterfaceOrientation = YES in all files
Although if you're using mixed modes, you might be better off with
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

Resources