Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple Custom UIView Class Broken
    primarykey
    data
    text
    <p>I have made a simple subclass of UIView which has a few subviews but its breaking for a reason I can't see.</p> <p>In my storyboard view controller I have added a UIView and made it the shape I want it, and added my custom class to it. The contents of my subclass is below:</p> <pre><code>@implementation PersonDetailCell @synthesize button, requiredMarker, textField; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } -(void)layoutSubviews { [self setBackgroundColor:[UIColor colorWithRed:87.0f/255.0f green:153.0f/255.0f blue:191.0f/255.0f alpha:1.0f]]; textField = [[DetailTextField alloc] initWithFrame:CGRectMake(10, 0, self.frame.size.width -20, self.frame.size.height)]; [textField setFont:[UIFont fontWithName:@"Helvetica" size:14.0f]]; [textField setTextColor:[UIColor whiteColor]]; [textField setHidden:YES]; [self addSubview:textField]; button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [button setHidden:YES]; [self addSubview:button]; requiredMarker = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 4, 22)]; [requiredMarker setBackgroundColor:[UIColor redColor]]; [requiredMarker setHidden:YES]; [self addSubview:requiredMarker]; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ @end </code></pre> <p>Then in my view controller code I have imported my subclass and hooked up an IBOutlet of it to my view in my storyboard. In my viewDidLoad of my view controller I also try setting background colour of this view but nothing happens.</p> <p>All of my code runs without crashing, but my issues:</p> <ol> <li><p>I can't set the background colour from my view controller, (or any other properties for that matter).</p></li> <li><p>When I run the app, the height is more than that I set in my storyboard (width is fine), but I change the height of the view nowhere.</p></li> </ol> <p>Any ideas? Am i using the wrong approach somehow?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload