Objective c 是否有方法在有限的帧上显示Uitableviewcell选择?
我有一个uitableview单元格,添加了一些类似这样的标签Objective c 是否有方法在有限的帧上显示Uitableviewcell选择?,objective-c,iphone-sdk-3.0,uitableview,Objective C,Iphone Sdk 3.0,Uitableview,我有一个uitableview单元格,添加了一些类似这样的标签 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentif
- (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] autorelease];
UIImage* myImage = [UIImage imageNamed:@"AccessoryForDealsMain.png"];
UIImageView *MyimageView = [[UIImageView alloc] initWithImage:myImage];
MyimageView.contentMode=UIViewContentModeScaleToFill;
cell.accessoryView=MyimageView;
[MyimageView release];
UILabel *BluePatti = [[UILabel alloc] init];
BluePatti.frame=CGRectMake(0,0,4,44);
BluePatti.backgroundColor = BLUEPATTI;//[UIColor blueColor];
UILabel *BlackLine = [[UILabel alloc] init];
BlackLine.frame=CGRectMake(3,0,1, 45);
BlackLine.backgroundColor = BLACK_LINE;
[BluePatti addSubview:BlackLine];
[BlackLine release];
[cell.contentView addSubview:BluePatti];
[BluePatti release];
UILabel *Seperator = [[UILabel alloc] initWithFrame:CGRectZero];
Seperator.backgroundColor = [UIColor colorWithRed:234/256.0 green:234/256.0 blue:234/256.0 alpha:1.0]; //[UIColor lightGrayColor];
Seperator.frame = CGRectMake(4,43,316,1);
[cell.contentView addSubview:Seperator];
[Seperator release];
}
if(indexPath.section==5)
{
cell.textLabel.text=[self.GenderCellData objectAtIndex:indexPath.row];
cell.textLabel.textColor=CELL_TEXT_COLOR;
cell.textLabel.font=CELL_FONT;
}
else
{
cell.textLabel.text=@"Cells";
cell.textLabel.font=CELL_FONT;
}
return cell;
}
现在,当我触摸单元格时,它会在所有子视图上方显示蓝色选择。如何更改选择框和颜色?您可以在UITableViewCell中创建一个具有自己的框和颜色的自定义。当选择单元格而不是默认的蓝色背景时,将显示此信息
例如:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 20, 30, 40)];
view.backgroundColor = [UIColor redColor];
cell.selectedBackgroundView = view;
[view release];
您可以在UITableViewCell中创建具有自己的框架和颜色的自定义。当选择单元格而不是默认的蓝色背景时,将显示此信息
例如:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 20, 30, 40)];
view.backgroundColor = [UIColor redColor];
cell.selectedBackgroundView = view;
[view release];
今天我面临同样的问题,我通过这个代码解决了这个问题 首先,在我的自定义cell init中 第二组选择样式无 表中第三种方法
今天我面临同样的问题,我通过这个代码解决了这个问题 首先,在我的自定义cell init中 第二组选择样式无 表中第三种方法
但它显示在完整的单元格上。我用过这个。我只想在有限的帧上显示选择,但仍然没有成功。是的,我同意您不能设置自己的帧。反正对我不起作用。但它显示在完整的单元格上。我用过这个。我只想在有限的帧上显示选择,但仍然没有成功。是的,我同意您不能设置自己的帧。反正对我不起作用。
cell.selectionStyle = UITableViewCellSelectionStyleNone;
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
CustomOrderTableViewCell *cell = (CustomOrderTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
[cell.customerbgImageview setHidden:NO];
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
CustomOrderTableViewCell *cell = (CustomOrderTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
[cell.customerbgImageview setHidden:YES];
}