View Full Version : View

Dec 14, 2009, 04:01 AM
I defined a UIView "RowOfThree" inwhich there are 3 labels. i also defined a UIView "Table" inwhich there are numer of objects of type "Row".
the following code is in a method within object "Table":

RowOfThree *rowOfThree = [[RowOfThree alloc] init];
[self addSubview:rowOfThree];

for some reason it doesn't add the view.
i tried defining the labels in "RowOfThree" both in IB and programmatically and it still didn't work.
Thank you.

Dec 14, 2009, 10:09 PM
You probably need to give rowOfThree a frame. It most likely has a size of {0, 0}. Example:
rowOfThree.frame = CGRectMake(0.0, 0.0, 50.0, 50.0);

Dec 15, 2009, 03:12 PM
You say you implemented rowof3 in an IBOutlet, that should like this:

@class RowOf3
@interface WhateverName : UIView {

IBOutlet RowOf3 *rowof3;


But did you also call RowOf3.h at the top of your class (.m) file? Another thing you could do is:
RowOf3 *rowof3=[RowOf3.h initWithNibName:[NSString stringWithFormat:@"NibName.xib"]];
//With this example I do not think you need to call rowof3 the IBOutlet
and make a RowOf3.xib file. One last thing. If you've already declared RowOf3 as an IBOutlet, you can simply do this to add it to the current view:
[self addSubview:rowof3];
Those are my suggestions, tell me if they work!

Edit: Sorry, i misread your post, you said you implemented the view in interface builder, not IBOutlet, but you still should make it an IBOutlet, as I showed.