UITableViewCell添加照片按钮,如联系人应用程序?

时间:2011-10-26 00:15:24

标签: iphone objective-c xcode cocoa-touch ipad

如何在联系人应用中添加照片按钮来创建UITableViewCell?

UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(20, 1, 70, 40)] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:16];

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(70, 10, 217, 30)];
textField.backgroundColor = [UIColor clearColor];
textField.returnKeyType = UIReturnKeyDone;

[cell.contentView addSubview:label];
[cell.contentView addSubview:textField];

3 个答案:

答案 0 :(得分:0)

只需添加UIButton并将拇指图片设置为其backgroundimage或imageview属性。

答案 1 :(得分:0)

将照片添加到tableviewcell并不太复杂。

UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setFrame:CGRectMake(5,0,40,30)];

[btn setBackGoundImage:[UIImage imageName:@"ABC.png"]];

[cell.contentView addSubview:btn];

如果您希望您的应用程序与Iphone中的联系人应用程序类似,那么您需要使用scrollview而不是tableview。

答案 2 :(得分:0)

最简单的方法是使用xib创建UITableViewCell的自定义子类。然后你只需要像{/ p>这样的-tableView:cellForRowAtIndexPath方法选择你的单元格

myCustomCell *cell = (myCustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

然后配置它们