UIStatusBar + toggling full frame video + rotations = frame problems - ios

My video (AVPlayer instance) plays in a smaller "minimized" window to start. Touch the screen to show the controls, and allow the user to expand it to full screen, which covers the status bar. I'm giving the viewController this for its full frame:
[[UIScreen mainScreen] bounds]
But the viewController still thinks the status bar is there, even if I hide it first:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]
So the video screen starts below the unseen status bar, at (0, statusBarHeight). If I rotate the device with the controls visible (which makes the status bar visible), the problem remains. If I rotate the device when controls are hidden (and the status bar is missing), everything corrects itself, and the video window starts at (0,0) as expected.
My solution has been to start the full screen video window at (0, -statusBarHeight), then watch for a rotation with no controls, when I can then put the video window back to origin. Yuck.
When I minimize the video back to the original size, if there has been a rotation with no controls, the video window will be too high by (statusBarHeight) pixels.
So another boolean to tell me, when I minimize the video, if I should correct it's "real" position by (0, +statusBarHeight). Double yuck.
If, at this point, we rotate the device, everything is good. But if we instead maximize the video right away, then the full screen video is too high by (statusBarHeight) pixels. Triple yuck!
Okay, more booleans, but this is all complicated by the fact that the video engine is a separate framework, and the 'controlling app' also has similar problems.. AAH!
Am I going about this in the wrong way? It's just getting all too complicated and fragile. I know (by looking at other apps out in the wild) that this is a common problem - I have a list of apps that exhibit the same behaviour. Is there a better way?

I wrote a very simple app to recreate this problem, and used up a "Technical Support Incident" to ask Apple's Developer Technical Support about it. They advised me to file a bug report (ID 12685127). They say:
AVPlayer is definitely not taking into account the status bar ..
and
I'm afraid I don't see a better solution, other than correcting for this as you are doing now ..

Related

IOS: Smooth launch when becoming active

When my app has been inactive and I then click on it, initially it brings up the last screen it was on. Then it segues to the the entry screen.
This is a bit jarring especially because the entry screen is a New screen and if nothing is New, it, in turn, segues to yet another screen.
Is there a way to better control what happens on return to active so that it stays on the last active screen or goes straight to the entry screen without first flashing the last active screen? I imagine this may have something to do with applicationWillEnterForeground: but with no experience with this, I find Apple's documentation fairly dense going.
You want to check out state restoration, which is a way for you to implement a seamless transition to the last point the user left off. There are also great WWDC videos on it.
https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/PreservingandRestoringState.html

Animation in Launch Screen in xcode 6

I want to animate a set of images in my Launch Screen, but I do not know how. I have seen some tutorials telling me to put code in the App Delegate (DidFinishLaunchingWithOptions) and nothing has worked.
Could someone help me animate my Launch Screen?
I am supposing that you do quite a bit of work on launch, and you do not want your user to stare at a static image while this work is going on. What you need to do is do the work in the background (using gcd). This way, the launch screen will be gone quickly. However, you are not ready of course: hence your need for animations. So what I do is add my own equivalent of the start screen on top of my first visible UIView, do my animations and then tear down my start up screen. If you want to see what I do in action, try it out with my App (The Opera Player)

cocos2d 3.x prevent screen rotation

I am using Cocos2d 3.x and I want the screen orientation to be completely locked. I am creating an app that uses the accelerometer information to move a sprite in the x and y directions. When I lean the screen forward too far, the screen switches from landscape orientation with the button on the left to landscape orientation with the button on the right. I never want this to happen; I always want the orientation to remain landscape orientation with the button on the left. I would assume this is easy to do, and it has already been answered, but after searching for quite some time I still can't figure it out. Any suggestions? Thanks.
OK, I finally figured it out. In the function supportedInterfaceOrientations in CCDirectorIOS.m I always return the value UIInterfaceOrientationMaskLandscapeLeft.

Force rotation without user knowing

My app allows a user to create an invoice. Data can be input in either landscape or portrait.
The user is then able to save the quote and view saved quotes in a collection view. Similar to Pages on iOS. The size of the tiles are the aspect ratio of the device in portrait view.
So if the user saves a quote I generate a screen shot of the view and save it so that it can be viewed in the tiled view (like iOS pages). This works all fine if the user saves when the device is in portrait. If they save while landscape it sucks.
So my question is, there a way I can rotate the view behind the scenes, generate a UIImage from it all without the user knowing noticing any orientation change.
If you are running the code that rotates it and takes a screenshot in the same thread then as long as you rotate it back before the thread finishes running, the device's screen will not update. Simply rotate everything (or if you have too many objects to rotate, take a screenshot of it all then rotate that screenshot) now take a screenshot of your new rotated view (or if you took a screenshot and rotated it don't do anything, you're done) then rotate everything back (again unless you just took a screenshot then rotated that)... If you need a screenshot method that can run in 1 thread use the CGContext code.
(To answer your question, rotating is always behind the scenes, it only becomes "in front" of the scenes when your thread ends... so if you rotate it back before the end of your thread the user will never see it because the device's screen will not update until after it has been rotated twice, there and back again.... bingo!)

ipad sprite/atlas animation

I have an iPad app, where I need an animation full screen - running in a transparent UIView.
This animation is running every time the user is winning.
The question is, would you go for a sprite animation with a very large image as the source or would you go for a small video clip?
Remember that it has to be transparent - it is starts floating around.
Any input regarding directions is appreciated.
Thanks
I would use a sprite, loading a movie each time user wins is much more expensive than simply showing a sprite.
Besides, to show a video with transparent background you will have to iterato throught all player controller subviews and change backgroundColor like this

Resources