I'm playing around with a really simple game for the iPhone based on the CrashLanding example on the developer center. I've extended it a little so that rather than using OpenGL for display all the time I have a plain UIView as the title screen, a UITableView for a high scores screen and an unmodified EAGLView for the game screen.
So all works well setup like this except that when I try and re-display the EAGLView the screen stops updating. I have a game loop that starts and stops when the screen is displayed and hidden and I initially thought that this wasn't restarting but through debugging the application that all seems good. I then thought that maybe I needed to recreate the OpenGL surface when it's redisplayed so I did and the screen went from all black to all pink.
I'm using a UINavigationController to handle moving between views. The error happens after going from the root view controller (Title screen) to the EAGLView (game screen) then going back to the root view controller and going to the game screen again.
Any info/help would be greatly appreciated!
Many months later...
This turned out to be an issue with using the EAGLView inside a UIViewController. To fix it I pulled the EAGLView out and sat it behind the controller. So to show it I just have to hide the controller. Not so nice but it allows me to switch between it and other views without any issues.
Related
I'm trying to make an animation where the word contained in the middle of the screen has its letters that get highlighted one by one using an image overlay on which I increase the alpha from 0 to 0.5 over a short period.
My problem is, even though the animation is fine in the scene view and when previewed, the overlay image seems to be duplicated out of nowhere and always in the same place.
Those duplicates do not appear in the scene view but they do appear in the game view and I can see no reason for them to show up.
Here are screenshots from the scene and game view :
EDIT : After more tests it is definitely an animation problem. The animation runs as it should in the scene view but on some letters, in the game view, it is misplaced and scaled differently.
Here are some more screenshots of what is going on :
Scene view
Game view
Ok so this was kind of silly mistake. It was caused by a z value on my animated object set to -1595. Setting it to 0 did the trick and the animation is now playing normally.
My app is displaying the correct iOS loading screen, and then a white screen.
Is it incumbent on me to overwrite the white screen appropriately? Before I added loading screens, I had a background view loaded, and images on top of it. Now it just is plain white.
For displaying the background correctly, does it make sense to have a draw screen method, called from viewDidLoad and from viewDidRotate, and tackle things from there?
I have a ContainerView under a ScrollView, and the ScrollView is provisionally 150x150, which should even if it clips things show non-white pixels inside.
What should I do to get real diagnostics?
My app is displaying the correct iOS loading screen, and then a white screen.
Something is wrong with your initial view controller, or with the view that it's supposed to load.
Is it incumbent on me to overwrite the white screen appropriately?
The white screen is probably either your app's window or an empty view. Normally, your app delegate would create a root view controller and load its view into the app's window (possibly automatically if you're using storyboards). It sounds like something happened to adversely affect that process -- your storyboard was changed, your Info.plist (which points the app to the right storyboard or .xib file) was changed, etc.
For displaying the background correctly, does it make sense to have a
draw screen method, called from viewDidLoad and from viewDidRotate,
and tackle things from there?
That shouldn't be necessary, at least in the context of your current problem.
What should I do to get real diagnostics?
Use the debugger. Is the window's root view controller pointing to an instance of the correct class? If yes, does its view property point to the correct view? If yes, does the view contain the appropriate objects?
My rootViewController is a UITabbarController and contains UINavigationControllers.
In order to restrict rotation, since iOS6, on some but not all views, I have subclassed both of the these controllers to respect the shouldAutorotate response of their topmost or visible view.
This all works just perfectly... most of the time.
In one case, starting from a view (UITableviewController) that does not allow rotation.
I push a view that does allow autorotate, rotate to landscape then back to portrait.
Then when I pop the view, all appears well.
But now if I rotate the device, the status bar alone rotates, leaving a blank space at the top and covering a part of the left side of the current view. The current view does not rotate (as it should not). Only the status bar rotates, back and forth. The view remains responsive, receives touches and works as normal, doesn't resize or respond to rotation in any way (as it should not).
This behavior continues until I kill and restart the app. Once it happens I have found no other way to make it stop. On restart all works properly again and will work properly for an indeterminate duration. I can sit there pushing, popping, rotating back and forth to my hearts content with no issues.
I have never been able to recreate this in simulator.
It happens for no apparent reason, I cannot make it happen. I'd say 85% of the time it works properly. I thought I had it fixed many times when it did not occur for days or even weeks. Then, out of the blue it happens again.
I cannot find a post in any forums which describe this behavior, so I am not finding even a place to start to debug. How could the status bar swing from top to side and the view does not resize or rotate or respond in any way. If I knew how to make that happen, I would have a place to start.
I experienced the same problem when adding a subclassed UIWindow (in my case, a status bar overlay).
The solution was to set the rootViewController of this new UIWindow to a subclassed UIViewController that had -(BOOL)shouldAutorotate implemented. This prevented the status bar from rotating when it wasn't supposed to.
There are a number of similar questions on this site about discovering the orientation of the device in applicationDidFinishLaunchingWithOptions being problematic, but I've yet to find a working solution. The problem I have is that I am adding a full screen image (identical to the currently chosen Default-XXX.png being displayed by the OS to my main window. I do this in order to have an animation happen from the 'splash screen' to my first view controller's view.
Works great, except the device keeps telling me that it is portrait mode - meaning I can't match the image being displayed consistently, since I have different graphics for each orientation)
My understanding is that all apps default to portrait orientation until a rotation occurs inside the app (usually when presenting a viewController) but I'm not 100% convinced.
You should be able to solve this using a view controller. When the application has finished launching, present a view controller in the window. Override the shouldAutorotate… query so that the controller autorotates to portrait/landscape and when you receive one of the rotation callbacks, update the image in the view accordingly. The controller will start up in portrait, but if the device is in some other orientation, the rotation callback will immediately follow and you will get the correct image.
P.S. You might find the Orientation Zoo project helpful when debugging this.
I've modified the ViewTransitions app to use kCAScrollHorizontally. I've set transition in the app delegate to use kCATransitionPush rather than kCATransitionFade. However, I still get fading in and out. How can I get the views to slide in landscape just like the Star Trek app (http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=305916616&mt=8)?
I've done transitions like this before. Basically I have a big view that takes up the screen, with another view (the actual screen content) embedded within it. When I want to slide in a new page either from the left or right, I'll take the next page of content, place it offscreen, and embed it in the big backing view. Then I'll just animate (using a simple [UIView beginAnimations:context:] to change the frames of both pages simultaneously (really just changing the origins of the frames). The offscreen view slides to where the current view is, and the current view slides to an offscreen position. Once offscreen, I'll remove it from its superview. Works like a charm.
The simulator will still fade out rather than performing some complex transitions...
Did you try it on the device?