0

I though I understood this, but I can't get it to work:

I'm trying to create a very simple app, to test various things (OK - it's an app to estimate Pi using the Monte Carlo technique by simulating throwing darts at a board).

I have a single view iOS app (e.g. from the single view template) on which I've simply got one UIButton (to launch the app) at the bottom and a UILabel at the top to show the results.

The view controller is a custom subclass of UIViewController call PiCalcViewController; the view is a standard UIView filling the whole screen.

The app works but now I want to be able to draw a graphic representation of how the simulation is going the middle of the screen, which I'll do in my view's drawRect (right?). So I thought that I'd create a new file (PiCalcView) an Objective-C class, make it a subclass of UIView and then, in IB, drag out a new view in the middle of my view controller and change it's class to PiCalcView.

Great, except that PiCalcView does not appear in the drop-down class list in the inspector.

Questions : Any idea what's wrong and is creating a subview of my UIView like this the right way to do it?

Steve Ives
  • 7,894
  • 3
  • 24
  • 55
  • 1
    Have you tried writing PiCalcView into the drop down list and hitting enter and saving? I have had occurrences in the past where a view hasn't appeared in that dropdown but worked fine after typing it in manually. – AndyDev Oct 01 '12 at 19:42
  • 1
    I had the same problem sometimes for a few times after upgrading to Xcode 4.5. I worked on something else and come back later every time it happens, and the new Class appeared again. – John Oct 01 '12 at 19:46

2 Answers2

0

Type the class into the custom class section in the Identity Inspector.

njkremer
  • 269
  • 3
  • 11
  • It allowed me to do that, but from the tutorials I had been following I knew that my custom class should appear in the drop-down. I dragged in other custom UIViews from other projects, and they appeared to work. – Steve Ives Oct 01 '12 at 19:52
0

OK - quitting and restarting Xcode appeared to do the trick.

Thanks for the tips - being new to Xcode & ObjC, I didn't know if I had the right technique.At least I know now.

Steve Ives
  • 7,894
  • 3
  • 24
  • 55