1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

View

Discussion in 'iPhone/iPad Programming' started by yaniv92648, Dec 14, 2009.

  1. macrumors member

    #1
    Hi,
    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

    kainjow

    #2
    You probably need to give rowOfThree a frame. It most likely has a size of {0, 0}. Example:
    Code:
    rowOfThree.frame = CGRectMake(0.0, 0.0, 50.0, 50.0);
     
  3. macrumors regular

    drf1229

    #3
    You say you implemented rowof3 in an IBOutlet, that should like this:
    Code:
    @class RowOf3
    @interface WhateverName : UIView {
    
    
    IBOutlet RowOf3 *rowof3;
    
    }
    @end
    
    But did you also call RowOf3.h at the top of your class (.m) file? Another thing you could do is:
    Code:
    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:
    Code:
    [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