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.
Related
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 :)
In iOS 7 and earlier, if we want to find topMostWindow in application, we were commonly using following line of code
[[[UIApplication sharedApplication] windows] lastObject]
This will commonly return UITextEffectsWindow if there is keyboard available on screen else it returns UIWindow.(This is common scenario, not always true)
But, In iOS 8, when i use above command it always gives me UITextEffectsWindow. Also, [[UIApplication sharedApplication] windows] always contains 2 objects(UIWindow and UITextEffectWindow). What should i do to get FrontMostWindow in case of iOS 8.
I think the (internal) UITextEffectsWindow is in fact the frontmost window. So I guess the question is not how to get the frontmost window, but what window you want to get.
Maybe you are looking for the key window? (From the docs: "The key window is the one that is designated to receive keyboard and other non-touch related events.")
So this would be
[[UIApplication sharedApplication] keyWindow]
I think this is the front most window from an end user's perspective (in all cases I have seen so far).
This question already has answers here:
Is there a way of adjusting the screen brightness programmatically?
(3 answers)
Closed 9 years ago.
Before iphone lock the screen, it will dim the screen first for a while. I wonder how to lighten the screen in my app at that time without touching the screen. Can anyone give a help?
To be more specific: I don't want to prevent the system sleep, nor adjust the screen brightness. What I want is to lighten the screen when I got a certain event to notice the user while the screen is dimmed.
Just solve this problem in a tricky way..
- (void)lightenTheScreen
{
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
}
That is default behavior of the iPhone. To prevent that nature you can use following code.
[[UIApplication sharedApplication] setIdleTimerDisabled: YES]; //Add this at the end in your applicationDidFinishLaunching application
From APPLE DOCUMENTATION
"The default value of this property is NO. When most applications have
no touches as user input for a short period, the system puts the
device into a "sleep” state where the screen dims. This is done for
the purposes of conserving power. However, applications that don't
have user input except for the accelerometer—games, for instance—can,
by setting this property to YES, disable the “idle timer” to avert
system sleep. "
How can I get this small thumbnail status on the right corner of the icon?
You can use the setApplicationIconBadgeNumber: method to set the badge to any number you want. This message should be sent to an instance of UIApplication. To get the current application, you simply call [UIApplication sharedApplication].
Your code would look like this:
int number = 25; //set this to any number you want
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:number];
Or, you can obviously set it at once, without the extra variable, like this:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:25];
For the badge see
http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instp/UIApplication/applicationIconBadgeNumber or use
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:68];
For the new icon, you can't this is done by apple when you download a new application and it hasn't been opened yet.
Use application badge to set like that.
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:68];
For more reference, see this
Also see UIApplication documentation
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.