tags:

views:

508

answers:

2

I am trying to create a custom UIView that is stored in a nib so that I can position it using Interface Builder.

I have created a class called RippleView that extends UIView. I'd like to position this view as a subview using Interface Builder. To do so, I've dragged a new view into my existing view in Interface Builder and gave it the RippleView class identity. I then linked my RippleView outlet to the view I just created.

In the RippleView class, I've implemented initWithCoder which doesn't do anything other than call [super initWithCoder...]. In awakeFromNib I go ahead and initialize my code.

Now, for some reason, if I try to check the bounds of the RippleView in awakeFromNib, I get ridiculous values (0 width and 1081171968 height). These bounds don't change in drawRect, so I don't think it's an issue of the view not being initialized. I get similar values in my touchesMoved event handler.

I had no problems when I was programmatically creating the subview (initWithFrame). What could be causing the frame bounds to go haywire?

A: 

Can you post your initWithCoder: implementation? If you're not setting the value of self, or if you've misspelled initWithCoder:, you might see these sorts of problems. Have you tried setting a breakpoint in initWithCoder: to make sure it gets called?

Mark Bessey
A: 

Solved! The issue had nothing to do with the code. The UIView bounds are floats and I was printing them as integers. It's things like this that separate the programmers from the dropouts :p

Kai