Missing part at page 335 - Adding a view via a xib


#1

So, I was just going over this chapter and specifically the part where our TouchDrawView is added to the MainWindow via Interface Builder. The view however is never actually configured to load in the book, or I’m missing something.

Anyway, this is what you need to do to make this work:

[ul]
[li] Drag a View Controller to the workarea[/li]
[li] Link the newly added View Controller to the instance of “Touch Draw View” via its view outlet[/li]
[li] Select the Window and connect its rootViewController outlet to the View Controller[/li][/ul]


#2

Thank you Ziggie,

I also had trouble getting the code from this chapter to display the TouchDrawView.

However…
The sample code seems to work fine – without using an intermediate UIViewController.

My problem turned out to be in TouchDrawView initWithCoder:
Instead of [super initWithCoder:c]; I had [super init];
So some chunk of the nib wasn’t being used, which explains why my view wasn’t getting correctly added to the Window.

So I’m not sure why you seem to need a RootViewController. My TouchTracker project (following the book) is now working fine.

-K


#3

Ziggie, it sounds like you might have missed the part where you set the class of the UIView you dragged into your MainWindow.xib to be TouchDrawView. Doing this creates the connection and means it will be automatically loaded by the application when it starts.


#4

As dezinerau said - look at fig. 20.2, that should solve your problem