I got a problem with my applications keyWindow on iPad.
I designen my app for iPhone and added the iPad support later by setting the device family and adding a new storyboard for iPad.
Everything is fine so far, I can open the app on the ipad and even the interface shows up as I customised it for iPad.
Now here comes the problem:
I don't know why, but the iPad version of my app doesn't have a keyWindow.
I need that because I display a loading dialog at the beginning that should lock the screen for user interaction, so I added it to the main window. On iPhone this works fine.
I figured out that "[UIApplication sharedApplication].keyWindow" gives me null, but only on iPad, whereat "[[UIApplication sharedApplication].windows objectForKey:0]" gives me the window object, which of course must exist because the app shows the complete ui.
The source files for ipad and iphone are, of course exactly the same, but I think I missed something when I added the iPad support later...
I already tried to set the window object in the application delegate to makeKeyAndVisible manually but with no luck. ([self.window makeKeyAndVisible];)
Does anyone has an idea what I have to do to make this working?
Kind regards
Ok I solved it myself.
I had to apply the makeKeyAndVisible method to my main window where I want to access it as keyWindow. I don't know why it doesn't work in the Application Delegate or why I have to set it manually for iPad and not for iPhone at all, but it works now.
If anyone knows why feel free to enlighten me.
Related
I used to have all my preview simulator device as iphone12 and I was fine with it. Not sure when, it all changed to I don't know iPhoneSE or iTouch with the thick bar. I did not want to change it back to iPhone12 by using the code .previewdevice() cuz I literally have like dozens of previews waiting for me to change, so I checked what decide the choice of the device. It shows as the screenshot below "inherited". There must be a source where I can the change the setting right? At least somewhere in the setting or I understand this "inherited" the wrong way? Can someone help give some more information about this? Can't believe xCode made this so inflexible...screenshot from my Xcode project,the mysterious inherited
Click on the run destination, which is something like iPhone SE. Just change it to the desired device type and the inherited device for previews will change accordingly.
If you want a special device type, as you said, just click on the top bar of the preview device and open the Inspect Selected Object menu (at the bottom of the Canvas), select the desired Preview Device. It will add the code .previewDevice("iPad (9th generation)") in the code preview section.
May app has two storyboards, where the default Main.storyboard is used for iPad, and another one named iPhone.storyboard is used for iPhone build. The storyboard to be used by the app is chosen in AppDelegate, in application didFinishLaunchingWithOptions after detecting which device is running the app.
For me, this two storyboard approach is very much simpler than working with adaptive layout, because of my app characteristics. But there is one side effect I couldn't overcome until now: when the app is installed on iPhone, the app icon is not being shown, even though I have the icon images for iPhone in Assets.xcassets. On iPad the icon is being shown correctly. Any ideas?
I have just discovered that I was using a wrong sized image for the icon. I had two separate projects for iPhone and iPad before. Funny that I made the same mistake then, but the iPhone app icon was shown anyway. I also made this mistake for iPad in this new joint project, but, as I mentioned before, I had no problem with the iPad icon. Sorry for bothering with this silly question.
I want my APP on iPad that A-View is Portrait-only and B-View is Landscape(Left or Right)-only.
I tried [application:supportedInterfaceOrientationsForWindow:] in my AppDelegate.m and [shouldAutorotate:][supportedInterfaceOrientations:][preferredInterfaceOrientationForPresentation:]in my NavigationController,ViewController which I used to show my APP(iOS 11).
It works well on iPhone, but when I try on iPad it doesn't work even [application:supportedInterfaceOrientationsForWindow:].
I want know how to control ScreenRotation on iPad.
Thank you very much.
Appreciate for your kindness help.
solved, just keep for reminder
iPad has the multipleScreen Function that it must support All-Rotation.
But when you check [Requires full screen]on Deployment Info, it means iPad now is full screen and the Rotation Function can work well.
In one of my projects, many built-in assets, such as the clear button in UITextField or UISearchBar objects, the UITableViewIndexSearch image, and the activity indicator in the status bar set by UIApplication.sharedApplication().networkActivityIndicatorVisible don't show at the correct resolution. I've noticed this on iPhone 6 and iPhone 6 Plus devices running iOS 8.4, as well as all of the simulators running iOS 8.4. I have other projects that don't show this issue.
Screenshots are here: http://imgur.com/a/7TMlE
I have experienced this as well, in my case the cause was various view controllers being created too early in the application life-cycle (in the init method of the app delegate, i.e. before didFinishLaunching had been called) and also before the creation of the initial UIWindow.
Moving view controller creation to didFinishLaunching, after the window has been created solved it.
Those are system elements, so that’s pretty weird. Try deleting and re-adding the simulators in the Xcode Devices window: Window → Devices or shiftcommand2.
I am following the course on iOS through iTunes university and working on the calculator project. I moved the controls on the storyboard to make room for another control at the top. Everything looks fine on the storyboard but when run in the simulator, controls are bunch up, on top of each other, and some are clearly off the top of the simulator screen. This leads to the following very related questions.
How does one move controls around on the storyboard? I went to the size inspector of each control (buttons in my case) and changed the 'Y' value (increased it by 10). I did this for each control. I didn't think about it as I was doing it because as I said, all looks fine on the storyboard. Is there a better way to move controls around? I could not figure out how to grab more than one control at a time and move them. Grabbing all and moving or all but one and moving would have been ideal.
I anticipate someone is going to say, "We need more info. " How do I show the storyboard? Is there a xml file somewhere? How is the storyboard saved? How should I show the results of the simulator?
In general, what the heck is going on? Why would things look so different in the simulator?
Is there a better forum/group to ask newbie questions about iOS programming?
My specs are these:
XCode 4.5.2
Ios simulator versions set to 6.0 and iPhone
Any other info needed? Thanks in advance,
Dave
Try setting your simulated device size to 'freeform' instead of 'inferred'. This screen is a bit smaller so the controls are no longer overlapping. The latest xcode sets it by default to ios6 (screen size of iPhone 5)
edit For a better insight in xcode IDE, please refer to the documentation provided by apple (includes screenshots for clarity)
https://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/000-About_Xcode/about.html#//apple_ref/doc/uid/TP40010215