我有一个正在自定义的表格视图,但是当我选择它时,它只选择了一半......看:
没有亮点:
突出显示:
我来自控制表格视图的类的代码:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
// create the parent view that will hold header Label
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(10,0,300,60)];
// create image object
UIImage *myImage = [UIImage imageNamed:@"trolley.png"];;
// create the label objects
UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.font = [UIFont boldSystemFontOfSize:15];
headerLabel.frame = CGRectMake(70,22,200,20);
headerLabel.text = @"Object";
headerLabel.textColor = [UIColor darkGrayColor];
UILabel *detailLabel = [[UILabel alloc] initWithFrame:CGRectZero];
detailLabel.backgroundColor = [UIColor clearColor];
detailLabel.textColor = [UIColor redColor];
detailLabel.text = @"Quantity";
detailLabel.font = [UIFont systemFontOfSize:15];
detailLabel.frame = CGRectMake(230,20,230,25);
// create the imageView with the image in it
UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage];
imageView.frame = CGRectMake(10,10,50,50);
[customView addSubview:imageView];
[customView addSubview:headerLabel];
[customView addSubview:detailLabel];
return customView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [lista count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
return cell;
}
我希望你能理解我!