Pet*_*rbo 15 dynamic uilabel ios
有时我希望我的视图包含5 UILabel秒,有时3秒,有时n.
UILabel的数量取决于从网站获取的数据.
tas*_*ari 34
您必须在代码而不是界面构建器中创建它们
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];
}
Run Code Online (Sandbox Code Playgroud)
一般性问题的通用答案:
while (labelsToDisplay)
{
UILabel *label = [[UILabel alloc] initWithFrame:aFrame];
[label setText:@"someText"];
[aViewContainer addSubview:label];
[label release];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26709 次 |
| 最近记录: |