Discussion in 'iOS Programming' started by yaniv92648, Dec 14, 2009.

  1. macrumors member

    Oct 26, 2009
    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.
  2. Moderator emeritus


    Jun 15, 2000
    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);
  3. macrumors regular


    Jun 22, 2009
    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.

Share This Page