Search code examples
iosxcodeuiviewuiviewcontrolleraddsubview

UIView won't let me add Sub Views


So I have a view and in my viewcontoller class I try and add a subview with the following code .

    UIButton *test = [[UIButton alloc]initWithFrame:CGRectMake(30, 100, 100, 100)];
    [self.view addSubView:test];

Nothing happens, no errors or anything. I know its being called because it is in the viewdidload method. I have a separate class were i subclass uiview could that have anything to do with it?


Solution

  • UIButton *test = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    test.frame = CGRectMake(30, 100, 100, 100);
    [self.view addSubView:test];