1
我有一個表格視圖。以下是我的cellForRowAtIndexPath代碼隱藏來自uitableview的特定視圖
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@""];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:nil];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
orderDetailsLabel = [[UILabel alloc]init];
shipmentStatusLabel = [[UILabel alloc]init];
ratingandFeedbackLabel = [[UILabel alloc]init];
HCSStarRatingView *starRatingView;
UILabel *suggestionsLabel;
UILabel *checkBoxLabel1;
UIButton *checkBoxButton1;
UIButton *saveButton;
UIImageView *checkbox1;
UITextView *feedBackTextView;
suggestionsLabel = [[UILabel alloc]init];
checkBoxLabel1 = [[UILabel alloc]init];
checkBoxButton1 = [UIButton buttonWithType:UIButtonTypeCustom];
checkbox1 = [[UIImageView alloc]init];
feedBackTextView = [[UITextView alloc]init];
if (indexPath.row == 0)
{
ratingandFeedbackLabel.frame = CGRectMake(20, 5, 350, 20);
ratingandFeedbackLabel.text = [ratingandFeedbackArray objectAtIndex:indexPath.row];
ratingandFeedbackLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:14];
starRatingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(20, 15, 100, 50)];
starRatingView.maximumValue = 5;
starRatingView.minimumValue = 0;
starRatingView.value = 0;
starRatingView.tintColor = [UIColor colorWithRed:254/255.0 green:174/255.0 blue:77/255.0 alpha:1];
starRatingView.backgroundColor = [UIColor clearColor];
[starRatingView addTarget:self action:@selector(didChangeValue:) forControlEvents:UIControlEventValueChanged];
}
else if (indexPath.row == 1)
{
checkbox1.frame = CGRectMake(20, 0, 20, 20);
checkbox1.image = [UIImage imageNamed:@"[email protected]"];
checkBoxButton1.frame = CGRectMake(20, 0, 20, 20);
[checkBoxButton1 addTarget:self action:@selector(checkBoxButton1Tapped:) forControlEvents:UIControlEventTouchUpInside];
suggestionsLabel.frame = CGRectMake(10, 185, 300, 30);
suggestionsLabel.text = @"Your feedback will help us make better *";
suggestionsLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:13];
CGRect screenRect = [[UIScreen mainScreen] bounds];
if (screenRect.size.height == 480)
{
tableView.scrollEnabled = YES;
feedBackTextView.frame = CGRectMake(18, 220, 285, 100);
saveButton.frame = CGRectMake(120, 330, 70, 30);
}
UIColor *borderColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0];
feedBackTextView.text = @"";
[saveButton setTitle:@"Save" forState:UIControlStateNormal];
[saveButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[saveButton addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
}
tableView.tableFooterView = [UIView new];
[cell.contentView addSubview:orderDetailsLabel];
[cell.contentView addSubview:shipmentStatusLabel];
//[cell.contentView addSubview:starRatingImageView];
[cell.contentView addSubview:ratingandFeedbackLabel];
[cell.contentView addSubview:suggestionsLabel];
[cell.contentView addSubview:checkBoxButton1];
[cell.contentView addSubview:checkBoxLabel1];
[cell.contentView addSubview:feedBackTextView];
[cell.contentView addSubview:starRatingView];
[cell.contentView addSubview:saveButton];
return cell;
}
在其他的方法來調用,receiveStarRatingData,我可是從用戶接收的狀態代碼。如果狀態碼是1,我不想顯示覆選框,suggestionsLabel,保存按鈕和feedBackTextView。我怎樣才能隱藏它們或從方法receiveStarRatingData中刪除它們?
您不斷添加子視圖的內容查看。這最終會使界面變得緩慢,有時甚至無法響應 – Joshua