Why doesn't iOS 5.0 work as an open window app? Why is he requesting the use of view controllers?

I have an iOS application that I created using the Xcode 4.0s "Window-based Application" template. Then it worked perfectly, and it used the iOS 4.3 SDK. This is an application that simply puts buttons, tags, etc. Directly out the window. No view controllers โ€” nothing.

But now that Ive upgraded to Xcode 4.2 (and its iOS 5.0 SDK) and I started the application, this message is logged on the console when the application starts in the simulator:

"A root view controller is expected at the end of application launch."

Of course, the application continues to work, but this rather annoying journal is printed every time it starts.

Why is this happening? Why does iOS 5.0 prefer / request view controllers?

+6
source share
3 answers

I don't know why the message is being logged, but the integration between UIWindow and UIViewController has been increasing over the past few iOS iterations. iOS 4 added the rootViewController property to UIWindow. Two classes work together to control the rotation of the view. Given the new features that iOS 5 introduced to the UIViewController (in particular, the ability to create custom container view controllers), it is clear that the relationship between the two classes will continue to evolve. As you said, your application continues to function in iOS 5, so having a root view controller is not yet a complex and fast requirement. Perhaps there are features planned for future versions of iOS that will depend on the availability of a view controller.

I have nothing against them, and I will use them if iOS wants me too. I was just curious about the behavior above.

I would interpret the post as a gentle, but constant push from Apple to provide a root view controller. Most applications already use view controllers anyway, so this is not a big change, but there are probably many applications that incorrectly set the window property rootViewController to their top-level controller.

+7
source

You just connected your โ€œviewโ€ to โ€œFile ownerโ€ ..... just delete this connection and run the application. Look at your view and look at the connection inspector area and delete that connection I said. I know exactly what the reason is. But I had this problem, and I cleared. Perhaps you used some kind of table view or some other views in it. So, the application. need a view manager to run. If you delete this connection, then it will run what you wrote only in the code ...

+1
source

Let me tell you the reason.

In a previous edition, Window-based Application was used to create multi-view applications. But in Xcode 4.2, the window application no longer exists. An empty application is designed to create a multidisciplinary program.

The difference between Window-based Application and Empty Application is that in the first there is the main window MainWindow.xib.

When the program starts, iPhone first creates the main window. Content in MainWindow will be uploaded and built. But if you want more features, such as multi-view, you still have a new root view controller. The root view controller can help manage the views in your program. In the new edition of Xcode 4.2, the root view controller is expected.

In the new edition in the Empty Application, the MainWindow.xib file is missing. Instead, AppDelegate creates a window. And he wants a root view controller. Thus, the best way is to subclass the UIViewController with the XIB for the interface for MainWindow. But in the old edition XIB is not needed.

It happened? Without a root view controller, you will not get an error, but you are unlikely to be able to do anything without it. This is why a warning always appears.

+1
source

Source: https://habr.com/ru/post/903998/


All Articles