1
我在表格視圖單元格上使用自定義UIImageView
和UITextField
。所有的工作,但是當我選擇任何細胞,imageview變得隱藏,但顯示文本字段。那麼問題是怎麼解決的?當選擇表格視圖單元格時顯示自定義UIImageView
這是我利用圖像和文本框上的tableview碼 -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellidentitifier = @"cell";
UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellidentitifier];
if (cell ==nil)
{
cell = [tableView dequeueReusableCellWithIdentifier:cellidentitifier];
}
else
{
[cell prepareForReuse];
}
UIImageView *imgview = [[UIImageView alloc]initWithFrame:CGRectMake(30, 10, 68, 70)];
imgview.backgroundColor = [UIColor blackColor];
imgview.userInteractionEnabled = NO;
imgview.layer.cornerRadius =YES;
[cell.contentView addSubview:imgview];
_nameTF = [[UITextField alloc]initWithFrame:CGRectMake(120, 10, 160, 20)];
_nameTF.placeholder [email protected]"Name";
_nameTF.layer.borderWidth = 1.0;
[cell.contentView addSubview:_nameTF];
_nameTF.delegate = self;
_nameTF.userInteractionEnabled = NO;
_nameTF = nil;
_addressTF = [[UITextField alloc]initWithFrame:CGRectMake(120, 34, 160, 20)];
_addressTF.placeholder = @"Address";
_addressTF.layer.borderWidth= 1.0;
[cell.contentView addSubview:_addressTF];
_addressTF.delegate = self;
_addressTF.userInteractionEnabled = NO;
_addressTF = nil;
_PhoneTF = [[UITextField alloc]initWithFrame:CGRectMake(120, 58, 160, 20)];
_PhoneTF.placeholder = @"Phone";
_PhoneTF.layer.borderWidth= 1.0;
[cell.contentView addSubview:_PhoneTF];
_PhoneTF.delegate = self;
_PhoneTF.userInteractionEnabled = NO;
_PhoneTF = nil;
_slotTF = [[UITextField alloc]initWithFrame:CGRectMake(30, 84, 250, 18)];
_slotTF.placeholder = @"Slot";
_slotTF.layer.borderWidth= 1.0;
[cell.contentView addSubview:_slotTF];
_slotTF.delegate = self;
_slotTF.userInteractionEnabled = NO;
_slotTF = nil;
return cell;
}
是的你是對的 – RaviJSS 2014-10-11 07:23:13