Iphone 如何将UIButton放入uitableview单元格?
我可以使用Iphone 如何将UIButton放入uitableview单元格?,iphone,uitableview,ios4,uibutton,Iphone,Uitableview,Ios4,Uibutton,我可以使用textlab和detaillabeltext创建tableview 除此之外,是否可以将ui按钮添加到单元格中 我的意思是在detaillabeltext之后,我可以放置一个ui按钮(比如“删除”按钮) 目前我有以下代码 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSInd
textlab
和detaillabeltext
创建tableview
除此之外,是否可以将ui按钮
添加到单元格中
我的意思是在detaillabeltext之后,我可以放置一个ui按钮
(比如“删除”按钮)
目前我有以下代码
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//-----------------------------------------------------------------------------------------------------
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
profileName = [appDelegate.sentItemsList objectAtIndex:indexPath.row];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
NSString *subjectData = [profileName.sent_subject stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
cell.textLabel.text = [NSString stringWithFormat: @"%@ ", subjectData];
cell.textLabel.font = [UIFont boldSystemFontOfSize:13];
NSString *CompanyName = [profileName.sent_content stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
cell.detailTextLabel.text = [NSString stringWithFormat: @"%@ ",CompanyName];
cell.detailTextLabel.font = [UIFont systemFontOfSize:10];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.backgroundColor = [UIColor colorWithRed:230.0/255.0 green:249.0/255.0 blue:230.0/255.0 alpha:2.0];
return cell;
}
谢谢你的时间和帮助 您可以向单元格的内容视图添加按钮或任何其他控件
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[cell addSubview:button];
UIButton *cellButton = [[UIButton alloc]init];
[cellButton addTarget:self action:@selector(uploadData:)forControlEvents:UIControlEventTouchDown];
[cellButton setTitle:@"Upload Now" forState:UIControlStateNormal];
cellButton.frame = CGRectMake(100, 180, 150, 35);
[cell.contentview addSubview:cellButton];
[cellButton release];
将任何控件添加到单元格的内容视图中您可以将按钮或任何其他控件添加到单元格的内容视图中
UIButton *cellButton = [[UIButton alloc]init];
[cellButton addTarget:self action:@selector(uploadData:)forControlEvents:UIControlEventTouchDown];
[cellButton setTitle:@"Upload Now" forState:UIControlStateNormal];
cellButton.frame = CGRectMake(100, 180, 150, 35);
[cell.contentview addSubview:cellButton];
[cellButton release];
将任何控件添加到单元格的内容视图中可能重复的,您想添加按钮吗?例如,如果要实现删除功能,可以使用附件,否则必须将所有内容都实现为表视图单元格的子视图。@rptwsthi:不象删除功能。我想调用我的“添加到收藏夹”按钮可能重复的,你想添加按钮吗?例如,如果要实现删除功能,可以使用附件,否则必须将所有内容都实现为表视图单元格的子视图。@rptwsthi:不象删除功能。我想叫我的“添加到收藏夹”按钮这是一个正确的解决方案,但它会隐藏所有以前的文本(标签和子标签)不,它不会隐藏以前的文本。。。给库里德correctly@rptwsthi:否则,您可以看到本教程。本教程很好。使用可以将图像也添加到单元格中。这是一个正确的解决方案,但它将隐藏所有以前的文本(标签和子标签)不,它不会隐藏以前的文本。。。给库里德correctly@rptwsthi:否则,您可以看到本教程。从本教程中,您可以使用它在单元格中添加图像