iOS create UILabels dynamically

后端 未结 6 788
甜味超标
甜味超标 2020-12-31 05:54

Sometimes I want my view to contain 5 UILabels, sometimes 3 and sometimes n.

The number of UILabels depends on data that\'s fetched fro

6条回答
  •  暖寄归人
    2020-12-31 06:56

    You'll have to make them in code instead of interface builder

     for (int i = 0; i < n; i++)
     {
        UILabel *label =  [[UILabel alloc] initWithFrame: CGRectMake(/* where you want it*/)];
        label.text = @"text"; //etc...
        [self.view addSubview:label];
        [label release];
     }
    

提交回复
热议问题