Dim iPhone back light on upside down - iphone

I have seen on an iOS application 'Sleep Cycle Alarm Clock' that when the iPhone is facing screen down (towards the floor) they have managed to dim the back light of the screen. I have been searching all over the internet and can't find the API that provides this functionality.
I am guessing that they achieve this by measuring acceleration on the device from gravity and dimming the back light accordingly, which I have no problem with. I just don't know how they have dimmed the back light (including the status bar!). It's not a semi-transparent black UIView overlayed on the superview, the light definitely switches off.
The detection isn't the issue, it's the dimming that I don't know how to do.
Can anyone point me to the correct method/API documentation? I'm using the iOS 6 SDK.
Thanks
EDIT:
Sorry guys, appears that I was wrong. Further investigation leads me to believe they haven't dimmed the backlight. The instructions stay over the superview temporarily. I think they actually overlay a black image and remove the status bar. My apologies! To get around the orientation lock for orientation detection I think they use the accelerometer.

Detecting if the device is face down can be done by using UIDevice orientation. This will return UIDeviceOrientationFaceDown when the screen is facing toward the floor.
Have a look at the UIScreen class for a couple of methods related to brightness.

Try this:
[[UIScreen mainScreen] setBrightness:0.5]; //Any value you think works
for more information about UIScreen and what you can do with it look at the documentation:
UIScreen Apple Documentation
EDIT: Just read the comments on the other answer, what kind of problems does this method cause?

Related

Swift sprite kit landscape only forced into portrait

I have asked this question before but maybe due to my bad explanation unfortunatly I did not get a reply. I am still having the issue with my spritekit game that is in landscape only.
When I lock my device or sometimes just switch to another portrait app, and than return to my game it is forced into portrait mode for 1-2 secs. This does not happen with other games and I do not understand what I am doing wrong.
I have set orientation to landscape left and right only (in Targets-General), changed the orientation settings in GameViewController.swift and also changed the Info.plist settings for "supported interface orientation" to make sure it is only landscape left and right.
What am I missing? I would appreciate any replies. Thank you very much
So it turns out after ages of research that it is the iAd Banners that cause this issue.
To fix it simply remove them from the superView in AppDelegate when application "WillResignActive" and reload them when application "WillEnterForeground".
Credits goes to Iganton
Background app screenshot showing wrong orientation after double tapping home

UIWebView slides down when tilting iPhone

In the simulator this does not seem to happen, because you can't tilt the simulator.
When I run a UIWebView on my device and tilt it seems to slide down and leave a gap of 44px, it seems to be the height of the NavigationBar at the top.
I don't have any code to post as I do not what is causing this.
When I go to another view and come back to this, the gap is gone as the iPhone didn't move between appearing.
Any ideas on what to do to stop this behavior?
I am using iOS 6 and Storyboard, if I can post anything to help, please let me know.
I have posted a screen shot from my device to show what is actually happen.
Well this can happen because of Auto Layout there might be a constraint that set it 44px below,
Check it out
Hope this will help ,
Further you can get the basic idea about AutoLayout feature from Ray Wenderlitch site http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2

Translate does not work in UIImagePickerController.cameraViewTransform

My app stopped working correctly with iOS 4.3. It uses a custom camera view overlay for the UIImagePickerController. And I want to adjust the size and origon of the camera preview view by set cameraViewTransform as CGAffineTransformMakeTranslation and CGAffineTransformScale, but the CGAffineTransformMakeTranslation seems to have no effect, However scale and rotate transforms work as expected. And the preview View is always in the center of the screen, I want to make the change.
I had try method as below, but does not work too.
Scaled live iPhone Camera view in center, "CGAffineTransformTranslate" not working
Any suggestion? Thanks.
Yes, I am seeing this on my 4.3 iPhone, but not on the ones with 4.2 and older. So it is definitely a bug.
I ended up just moving the picker frame to get this to work. check out my answer here: https://stackoverflow.com/a/9458688/791661

What is an effective way to deal with iphone orientation change while displaying an image

Disclaimer: I know the question of locking orientation has been asked, and solved. But that's only half my question.
I'm building an iphone website for a small indie game developer. They want to be able to show off screenshots from some of their iphone games. This is somewhat of a problem though. All the screenshots are taken from the game in landscape mode, so it really doesn't make any sense to display them in landscape.
Currently I have a very lightweight lightbox-style display for the image. You click a button on the site, and the image pops up (through ajax magic!) to occupy the full screen. Clicking anywhere on the image makes it go away, as if you had never viewed it.
I'm thinking that the two most practical solutions are either: a) lock iphone orientation for the duration of displaying the image; or b) do some very sneaky rotation on the image when the phone rotates, so no one ever notices. Are either of these possible/feasible? If so, could you give me any tips? And if not, has anyone solved a similar problem?
A demo of this is available at my personal server.
My $.02
As a personal design decision - I would have two images, and switch them as the rotation changes from portrait to landscape. Locking orientation seems so unfriendly. As some extra eye candy, You may want to put some sort of transition image in there between image swaps.
Here is something that may help .. http://snippets.dzone.com/posts/show/4912

iPhone app 'fake' landscape mode

So after wasting many hours trying to get my app to run in landscape mode by defualt I'm looking for an alternative.
My idea is to create the app in portrait mode but rotate everything by 90 degrees, the player thinks that he is playing the game in landscape mode (when really I've just rotated everything). I recognise it will be a little awkward to develop but I come into all sorts of issues when I try to program for landscape.
My question is, does Apple frown upon this? Could they reject my app for any reason or is this safe to do? Are there any issues I should be aware of?
Advice/articles/help all appreciated.
I do not allow landscape mode in my applications and none of them have been rejected. Sometimes an application does not benefit from being in landscape mode.
EDIT: The same also goes for portrait mode. If your app makes sense only in one orientation or the other, Apple will not reject you.
There is a key you can put into your Info.plist to make it start in landscape (see here). Or have you already tried that?
There are reportedly immersive full screen Open GL games that hide the status bar and do this. Note that you will still need to detect and handle landscape-left and landscape-right rotations or your app might appear upside-down.
Just set an affine transform on your top-level view, and be careful to always use the correct coordinate system.