Why doesn’t iOS 5.0 like plain window applications? Why does it request that view controllers be used? - ios

I have an iOS app that I created with Xcode 4.0’s “Window-based Application” template. It worked fine back then and it was using the iOS 4.3 SDK. This is an app that simply puts the buttons, labels, etc. directly onto a window. No view controllers—no nothing.
But now that I’ve upgraded to Xcode 4.2 (and its iOS 5.0 SDK), and I run the app, this message gets logged to the console when the app launches in the simulator:
“Applications are expected to have a root view controller at the end of application launch”
To be sure, the app continues to work, but this rather bothersome log gets printed out on every launch.
Why is this happening? Why does iOS 5.0 prefer/request view controllers?

I don't know specifically why the message is logged, but integration between UIWindow and UIViewController has been increasing over the last several iterations of iOS. iOS 4 added a rootViewController property to UIWindow. The two classes work together to manage view rotation. Given the new capabilities that iOS 5 introduced to UIViewController (specifically, the ability to create your own container view controllers), it's clear that the relationship between the two classes will continue to evolve. As you've said, your app continues to function in iOS 5, so having a root view controller isn't a hard and fast requirement yet. Perhaps there are features planned for future iOS versions that will depend on having a view controller available.
I don’t have anything against them, and I will use them if iOS wants
me to. I was just curious about the above behavior.
I'd interpret the logged message as a gentle but persistent nudge from Apple toward providing a root view controller. Most apps already use view controllers anyway, so this isn't a big change, but there are probably a number of apps out there that don't properly set the window's rootViewController property to their top-level view controller.

You have just Connected your "view" with "File Owner".....just remove that connection and run your app.click your view and see the connections inspector area and remove that connection which I told..I dont know exactly what reason..but i had this issue and i cleared.
May be you have used some tableview or some other views in it.So the app. needs a view controller to launch.If you remove that connection then it will run what you wrote in a code only...

Let me tell you the reason.
In former edition, Window-based Application is used to build multi-view applications.But in Xcode 4.2,the Window-based Application does not exist any more. Empty Application is designed to establish a multi-view program.
The difference between Window-based Application and Empty Application is that the former has a main window, the MainWindow.xib.
When the program starts, iPhone build the main window firstly. The content in the MainWindow will be loaded and built.But if you want more functions, e.g. multi-view, you still have to new a root view controller. Root view controller can help manage the views in your program. In the new edition,Xcode 4.2, a root view controller is expected.
In the new edition, there is not a MainWindow.xib in Empty Application.The AppDelegate create a window instead. And it wants a root view controller. So the best way is to create a UIViewController Subclass with XIB for interface for MainWindow. But in the old edition, XIB is not needed.
So get it? Without a root view controller, you are not going to receive an error, but you can hardly do any thing without one. That's why the warning always come out.

Related

What is the main Storyboard called in VLC ios?

Im trying to modify and learn from the ios open source code for ios.
Its a mixture of Objective C and Swift.
Is it possible to tell from the repo what the main storyboard is called? Id like to add a login screen that redirects back to the Initial screen but not sure how to get the Storyboard name
Here is the repo
https://github.com/videolan/vlc-ios
There is no “main storyboard”.
The app is created from the app delegate (like all apps were “back in the day”).
https://github.com/videolan/vlc-ios/blob/master/Sources/VLCAppDelegate.m
You can see in the function applicationDidFinishLaunching it creates a tabBarController and window and the passes the tab bar controller into a coordinator that will populate it with other view controllers.
This was the norm for all apps once. And is still a perfectly viable option for apps now too.

Why there are showing Two Storyboards in my every new xcode project?

Whenever I am trying to open a new project xcode always giving two story board and two View controller one DataViewController instead of showing one view controller and one story board .
I am using xcode 7.3.1
my versity hood was an old project of min which has only one view controller but
when i create new project everytime now i get two view controller like alamofire project. Point to be noted that it has started to happen after cocoapods installation and alamofire installation
please If any one knows how to fix it please help.
Are you talking about LaunchScreen.storyboard? If so, that is a special one (that can't be associated with code) that is used to draw something on the screen while your app is loading.
A common thing to do is to draw a version of your start screen with no controls (or all controls disabled) and no data yet (so it looks like it's loading).
Another common thing to do is some kind of splash screen.
You've chosen a wrong template. You need to choose Single View Application while creating your project. That gives you two storyboards and one view controller in Main.storyboard to start with. You have only 2 storyboards like normal. You just two ViewControllers and two ViewController classes. Nothing to worry. Just create a new project and select Single View Application in the beginning when it asks you to choose a template. It'll be fine.

UISplitView equivalent on the iPhone.

I have an iPad app which I am attempting to make universal and port over to my iPhone following this tutorial. http://www.appcoda.com/ios-univeral-app-tutorial/ (feel free to post a link if you believe it will help me).
So far, I have added a new storyboard file, named it Main_iPhone.storyboard and configured my target etc. However my iPad app is a UISplitView controller, with options on the side (in the master view) which control my detailview.
What I want to know is the iPhone equivalent of this object as i was made aware it cannot be used on the iPhone. Guidance needed on this one.
Thanks.
This is a very generalized answer since I have no idea what your app does.
The rootviewController of the app should be a navigation controller. The the root controller of the navigation controller should be the view controller that is on the left side of the split view controller. I'm going to assume that is a tableviewController.
When the user selects a row in the tableview controller, push the view controller that was on the right side of the split controller.
Now you have a master-child relationship.
Another thing to consider is that with the upcoming iOS 8 release, you'll be able to easily implement iPad like master-detail views on iPhone. (the concept is size constraint classes). As a developer, you can download the new xcode beta (and osx yosemite beta) to test this out.

App starting as Single view and proceed to tabbar application

I am about to create an xcode iphone app which will lauch initially as a single view ( something like login and settings screens ) and then proceed to a tabbed bar application with multiple tabs .
how to do this -
should i create two differnet projects one single view and one tabbed application ?
and is it possible to roll two projects into one single app ?
or is there just another easier way. I have xcode 4.3 and planning to use storyboard insteaod of XIBs
rgds,
sumit
Do not start with two projects, as you'll have an incredibly difficult time integrating them into one app. This is pretty simple, but you do need to learn the basics of view controllers.
Use Storyboards, and start with a single view app, maybe inside a navigation controller. Then do a transition to a tabbed view controller.
Upgrade to Xcode 4.6.3 or 5. Look at Apple's template apps for a tabbed application and a single view app to see how the storyboards look. Then copy the storyboards in one to the other, and link them up. This is definitely possible and straightforward, but you do need to understand how each view controller works with the others.
I also faced same situation once. I made a project as single view based app. without storyboard (since I was required to build compatible apps with iOS 4.3).
Made login screen as main view controller.
On login, I presented tab viewcontroller modally.
On sign out, I dismiss tab controller and return back to login screen.
If you have any queries, just ask it :)

Tabs, should it be a window or view?

When you build a tab application, should each tab be a view or a window?
Many developers say your app should only have one window with many views. Other developers say use windows for each tab.
Which is correct practice?
The general rule with iOS apps is that you want one UIWindow instance per physical screen. Until iOS added better multiscreen support, and the newer hardware was able to natively support app mirroring, most apps used one window, unless it explicitly supported a second display.
It follows then, that you want one UITabBarController to show instances of UIViewController objects. This rule should hold true regardless of the SDK you're using to write your apps, assuming that titanium maps its classes back to their native Objective-C counterparts.
The window doesn't have many views in a normal app, its simply hosts views while being displayed. I have never heard of using windows in tab views, I have several apps out that use tabbarcontrollers and I always use UIViewController subclasses (or UINavigationController subclasses) with a view in its nib - all works perfectly fine.

Resources