简体   繁体   中英

iOS Storyboard with Subclass of UIView

I'm following along with Stanford's iTunes U podcast for iOS development from Fall 2010. In the 5th lecture the professor shows how to create a custom view which is a subclass of UIView.

I'm using xCode 4.2 whereas the lecture uses xCode 3. I've written all the code to match the lecture except for some changes because of ARC in xCode 4.2.

I'm trying to get my custom view to come up on the app but I can't get it. I go into storyboard and am looking at the only view controller. I then add a view and make it of class FaceView (the custom view). When I build and run the app there are no errors but the face isn't drawn on the screen. If I make the main view object (the one that fills the screen) of class FaceView the face is drawn in the middle of the screen, but this isn't what I want.

How do I get it to draw my custom view?

I realize this was posted in October, so you probably figured it out by now. But we should answer it for the next person.

I'm going over the lectures as well, so I might be getting some terms (or worse) wrong. It seems to me that you are missing creating a connection between the controller and the view (an outlet).

You do this graphically in Xcode: Select the FaceViewController in your storyboard. There are two things in the black bar under: a "First Responder" and a yellow object icon. This is your view controller. Control-drag from the view controller to the UIView . Hope this solves it!

There is an updated course for iOS 5 (Fall 2011) on iTunes U, and in the course he does do a new FaceView.

He does it in the demo portion of Lecture 5. You can find the lecture notes and source code here: http://www.stanford.edu/class/cs193p/cgi-bin/drupal/node/267

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM