UIApplication removeStatusBarImageNamed doesn't work - ios

i'm working on a jailbroken iphone with iOS 5.0.1, just want to access status bar image,
and my code is as follows:
-(void)addStatusBarImage
{
NSLog(#"addStatusBarImage");
[[UIApplication sharedApplication] addStatusBarImageNamed:#"sgtest" removeOnExit: YES];
}
-(void)removeStatusBarImage
{
NSLog(#"removeStatusBarImage");
[[UIApplication sharedApplication] removeStatusBarImageNamed:#"sgtest"];
}
my problem is, the add function works fine, but removeStatusBarImageNamed seems useless as the "sgtest" image still exists in the status bar unless my app is terminated.

status bar icon manager fix what thread have had set icon image. if another thread try to remove that icon, it fails. You need to do it in one thread.
Check out SpringBoardAccess project at github. You can use it as is or implement like.

Related

Disable remote controls iOS

By default, remote control is activated on my streaming application but under a certain circumstance I want to disable all controllers and show nothing when the screen is locked.
First I tried to set now playing info to nil like this [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo: nil]; and all text, image and progress disappear but the control buttons and volume bar was still showing.
After that I tried this [[UIApplication sharedApplication] endReceivingRemoteControlEvents]; but it gives me nothing, it shows the same thing on the screen as the previous method call.
For the record, I'm calling [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; on AppDelegate before I tried to call any of the previous methods.
So, I have not found anything related to this that could help me with my problem and I would appreciate any help :)

Touch ID dialog showing a second status bar

When I let the user login into my app with Touch ID, I get the dialog (which by the way is very ugly and cannot be customized) and I also get a second status bar, which looks like this:
Is there any way to hide the status bar?
If not, set the status bar style to my style (UIStatusBarStyleLightContent)?
(I also would be very happy if someone knows of a way to customize the dialog, more than just changing labels)
i fixed this
just hide status bar when open touch id like this
[[UIApplication sharedApplication] setStatusBarHidden:YES];
not show after failure or success with perform selector with 1 sec delay like this and my code working perfectly
[[UIApplication sharedApplication] setStatusBarHidden:NO];
Did you see this behaviour on iPhone 6/6+ ?
If yes, the way I solved it was by setting the appropriate launching xib so that iPhone 6 and 6 plus devices are using the native resolution without being scaled. (see also this question on how to do that How to enable native resolution for apps on iPhone 6 and 6 Plus? )

iOS 7 red status bar

When Shazam is opened the status bar turns red and doubles it's height because of background recording, but this ruins the UI in my app. I'm now trying to change my code to support different status bar sizes, because the red status bar is also opaque, but I can't come up with a general solution because of this:
When the status bar is initially red, when I launch my app, the launch image is scaled and ruined. How to fix this?
Note: My app does NOT use recording.
[Edit]
The only solution I found was to set 'Status bar is initially hidden' to YES in .plist. I don't really need the status bar to be visible on app launch, especially if it affects my launch image when the status bar is taller than usual, i.e. when recording or during a phone call.
[Edit 2]
There are cases when the launch image will be briefly visible when the app is brought to foreground from background state. To work around this I use view-controller based status bar appearance:
- (BOOL)prefersStatusBarHidden
{
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground)
{
return YES;
}
return NO;
}
This ensures the status bar is always hidden when the app comes to foreground, so the launch image will never be affected. Don't forget to call setNeedsStatusBarAppearanceUpdate on appDidEnterBackground and (inside an animation block) on appDidBecomeActive notifications.
The red status bar is a system function. You are not going to be able to work around this - and it isn't really your 'fault' if the launch screen looks like that - if the user wants to open your app while using Shazam, they are going to see the red bar and the launch image is going to be scaled. You could change the launch image to look good when scaled, but then it would look bad the rest of the time (when the red bar wasn't at the top of the screen on launch).
After a long long long long long research and hurdles I found out simple solution for this follow as below
In Targets->General->Deployment Info check the HideStatusBar Option
like below!
And in the ViewController (Which one you kept as RootViewController) in viewDidAppear add this line of code...
[[UIApplication sharedApplication] setStatusBarHidden:NO];
Because when you uncheck HideStatusBar Option and your app needs any background process or audio related process then the status bar will become red with enlarged height. If you dont want status bar in entire app then dont add the above line in viewDidAppear and check HideStatusBar Option.

LibStatusBar icon disappears on 3rd-party app launch

I wrote a tweak for Cydia, it adds an icon to the status bar.
It works fine on the home screen and when SpringBoard is launched, also, if an app is already launched then it works fine,
however, if an app (such as Facebook or Twitter) is closed (completely) and the icon is showing, when launching the app, it will cause the icon to disappear.
The icon is displayed using libStatusBar using this code:
if(icon) // if icon needs to be removed
{
[icon release];
icon = nil;
}
...
// add the icon to the status bar
icon = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:#"muteIconLablabla"] alignment:StatusBarAlignmentRight];
icon.imageName = [NSString stringWithFormat:#"Mute"];
I also tried using the methods suggested in libStatusBar README file
[[UIApplication sharedApplication] addStatusBarImageNamed:#"ON_Mute"]; // and removeStatusBarImageNamed:...
I tried overriding -(id)init and updating the icon there, but the same result.
The code shown above is being called from a static void function. this function is being called several times, for example from -(void)applicationDidFinishLaunching:(id)application
under %hook SpringBoard and -(void)ringerChanged:(int)changed
All inside Tweak.xm.
The problem happens in iOS7 as well.
It's been a while since I've used libstatusbar, but if you are absolutely sure the LSStatusBarItem is not being released, it's possible it's being hidden by Springboard or another app. Consider setting icon.visible = YES explicitly. You also might want to consider setting timeHidden on LSStatusBarServer to NO explicitly by calling [item setHidesTime:NO].
Additionally, if you're not making any changes to the icon, set icon.manualUpdate = NO.
References:
Libstatusbar on the iPhoneDevWiki
LSStatusBarItem.mm source

iPhone display screen lights not turning off automatically

I have observed that my I run my iPhone application (native) the display lights are not turning off as they usually do in other applications, I have waited for couple of minutes but it wont turn off until I exit my application.
Is there anything which I had messed up with that is not causing the automatic dimming?
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Are the two lines to enable/disable the dimming of the screen in an iOS app. Double check and see if your app has any of these.
Put this code into application didFinishLaunchingWithOptions: method.
Have you used this in your app?
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
If so, remove it or set it to NO.

Resources