を働いていた、私はセルの表示を無効にするために、より良い好む、細胞のbackgroundColorプロパティを設定してみてくださいUITableViewによって呼び出されるあなたの細胞ビュー、ため、
後、私は私の仕事用のコンピュータを取得するとき、あなたの答えを見つけたhaventは場合、私はいくつかのサンプルコードを掲載します、
あなたが同様にあなたのセルの背景用の画像を配置し、あなたのセルのカスタムの場所で異なるラベルや画像、ボタン、テキストフィールドを配置することができ
あなたはそれがどのように動作するかを見たら210は
EDIT、非常に簡単です>>
コード! [背景を変更するためにやり過ぎばかりですが、あなたが本当にあなたのセルをカスタマイズしたい場合は、これが移動するための方法です!]あなたのCustomCell.hで
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell {
UILabel *_kLabel;
UILabel *_dLabel;
}
@property (nonatomic, retain) UILabel *kLabel;
@property (nonatomic, retain) UILabel *dLabel;
- (void) initLabels;
@end
あなたCustomCell.mに
#import "CustomCell.h"
@implementation CustomCell
@synthesize kLabel = _kLabel;
@synthesize dLabel = _dLabel;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
CGRect popUpImageBgndRect = CGRectMake(0, 0, 942, 44);
UIImageView *popUpImageBgnd = [[UIImageView alloc] initWithFrame:popUpImageBgndRect];
[popUpImageBgnd setImage:[UIImage imageNamed:@"tableCellBgnd.png"]];
popUpImageBgnd.opaque = YES; // explicitly opaque for performance
[self.contentView addSubview:popUpImageBgnd];
[popUpImageBgnd release];
[self initLabels];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
CGRect contentRect = self.contentView.bounds;
CGFloat boundsX = contentRect.origin.x;
CGRect frame;
frame= CGRectMake(boundsX+10 ,10, 200, 20);
self.kLabel.frame = frame;
frame= CGRectMake(boundsX+98 ,10, 100, 20);
self.dLabel.frame = frame;
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void) initLabels {
self.kLabel = [[[UILabel alloc]init] autorelease];
self.kLabel.textAlignment = UITextAlignmentLeft;
self.kLabel.backgroundColor = [UIColor clearColor];
self.kLabel.font = [UIFont fontWithName:@"FS Albert" size:16];
self.kLabel.textColor = [UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1];
self.dLabel = [[[UILabel alloc]init] autorelease];
self.dLabel.textAlignment = UITextAlignmentLeft;
self.dLabel.backgroundColor = [UIColor clearColor];
self.dLabel.font = [UIFont systemFontOfSize:16];
self.dLabel.textColor = [UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1];
[self.contentView addSubview:self.kLabel];
[self.contentView addSubview:self.dLabel];
}
-(void) dealloc {
[_kLabel release];
[_dLabel release];
[super dealloc];
}
@end
そして、あなたのViewController.m
を楽しむ
YourViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
中! ;)
それは完璧に男を働かせました!ありがとう! :) –
私は助けることができてうれしい –