在iPhone中添加一个UILabel

3

我有一个tableView,显示了一系列歌曲,当我点击其中任意一个时,它会被播放。

-(void) PlaySelectedSong:(id) sender{       
Song *aSong=[aCategory.Items objectAtIndex:appDelegate.selectedSong];
NSString *content1=[[NSString alloc] initWithFormat:@"http://192.168.50.108:8888/%@",[aSong.Link stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];

NSLog(content1);
NSURL *url=[NSURL URLWithString:content1];

NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the request in the UIWebView.
webView.delegate=self;
[webView loadRequest:requestObj]; 

这是它的播放方式。 问题在于,在播放时会显示歌曲的URL。我计划在上面添加一个标签,以便将标签文本设置为歌曲名称。

如何添加标签来实现相同的效果?有人知道吗?需要帮助。

谢谢, Shibin


请在歌曲播放时发布 UI 代码。 - kennytm
aSong.Link的内容是什么?请发布字符串。 - PirosB3
1个回答

1

需要更多信息才能回答这个问题,但听起来你想在表视图中有两个文本字段。

创建UITableViewCell时,请使用UITableViewCellStyleSubtitle样式。

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                               reuseIdentifier:cellIdentifier] autorelease];

然后,您可以在单元格中指定一个副标题,该副标题将使用显示。

cell.textLabel.text = songTitle;
cell.detailTextLabel.text = songUrl;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接