代码之家  ›  专栏  ›  技术社区  ›  shreyasva

如何在iOS上运行时创建控件

  •  0
  • shreyasva  · 技术社区  · 14 年前

    UIButton* tempButton = [[UIButton alloc] initWithFrame:CGRectMake(120, 160, 40, 40)];
    [self.view insertSubview:tempButton atIndex:0];
    [tempButton release];
    

    它不起作用

    1 回复  |  直到 14 年前
        1
  •  0
  •   Aaron Saunders    14 年前
    UIButton* tempButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] initWithFrame:CGRectMake(120, 160, 40, 40)];
    [self.view insertSubview:tempButton atIndex:0];
    [tempButton release];