0

Hii 可以将 UILabel 添加到具有 UIButton 作为子视图的 UITableView 单元中。我的意思是这个 UILabel 必须作为 DetailLabel 添加到 UIButton 中,即在按钮标题下方?

前我的编码是

    UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
    [button setImage:[UIImage imageNamed:@"launchpad.png"]forState:UIControlStateNormal];
    [button setTag:001];
    [button addTarget:self action:@selector(buttonPressed:)forControlEvents:UIControlEventTouchUpInside];
    [cell addSubview:button];

在标题文本下方,我希望标签作为子视图在运行时加载动态文本。

希望我解释清楚。请帮助我编写代码和添加 UILabel 的方法。

4

1 回答 1

0

您可以将此标签添加到 UIButton 作为子视图:

UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
[button setImage:[UIImage imageNamed:@"launchpad.png"]forState:UIControlStateNormal];
[button setTag:001];
[button addTarget:self action:@selector(buttonPressed:)forControlEvents:UIControlEventTouchUpInside];

UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0,24, 320, 20)];
label.text = @"Some text"
[button addSubview:label];

[cell addSubview:button];
于 2012-10-19T15:11:47.520 回答