Skip to content

Commit

Permalink
fix viewtag冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
gaosboy committed Mar 1, 2013
1 parent a90a556 commit 93f1bf9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions SegmentFault/SegmentFault-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
#define QUESTION_DETAIL_HEIGHT @"question_detail_height"
#define ANSWER_DETAIL_HEIGHT @"answer_detail_height"

#define QUESTION_LIST_CELL_ANSWER_LABEL 1000001
#define QUESTION_LIST_CELL_TAG_CONTAINER 1000002

#define CELL_HEIGHT 44.0f
#define SECTION_HEADER_HEIGHT 31.0f
4 changes: 2 additions & 2 deletions SegmentFault/ViewControllers/SFQuestionListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
CGFloat height = [SFTools heightOfString:self.questionList[indexPath.row][@"title"]
withWidth:300.0f
font:[UIFont boldSystemFontOfSize:16.0f]];
return height + 38.0f;
return height + 33.0f;
}
else {
return 58.0f;
return 53.0f;
}
}

Expand Down
16 changes: 8 additions & 8 deletions SegmentFault/Views/Cells/SFQuestionListCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ - (SFQuestionListCell *)questionListCell
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"qlist_cell_selected_background.png"]];

cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont boldSystemFontOfSize:16.0f];
cell.textLabel.font = [UIFont boldSystemFontOfSize:15.0f];

cell.detailTextLabel.numberOfLines = 1;
cell.detailTextLabel.font = [UIFont systemFontOfSize:24.0f];
cell.detailTextLabel.text = @"                 ";
cell.detailTextLabel.text = @"            ";
cell.detailTextLabel.textColor = [UIColor clearColor];

SFLabel *answersLabel = [[SFLabel alloc] initWithFrame:CGRectMake(0.0f, 4.0f, 40.0f, 17.0f)
andInsets:UIEdgeInsetsMake(1.0f, 4.0f, 1.0f, 4.0f)];
answersLabel.tag = 1000001;
answersLabel.tag = QUESTION_LIST_CELL_ANSWER_LABEL;
answersLabel.backgroundColor = RGBCOLOR(0, 154, 103);
answersLabel.textAlignment = NSTextAlignmentCenter;
answersLabel.textColor = [UIColor whiteColor];
answersLabel.font = [UIFont systemFontOfSize:12.0f];
answersLabel.font = [UIFont systemFontOfSize:11.0f];
answersLabel.layer.cornerRadius = 2.0f;
[cell.detailTextLabel addSubview:answersLabel];

UIView *tagsContainer = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 4.0f, 200.0f, 17.0f)];
tagsContainer.tag = 1000002;
tagsContainer.tag = QUESTION_LIST_CELL_TAG_CONTAINER;
tagsContainer.backgroundColor = RGBCOLOR(244, 244, 244);
[cell.detailTextLabel addSubview:tagsContainer];
}
Expand Down Expand Up @@ -80,7 +80,7 @@ @implementation SFQuestionListCell

- (void)updateQuestionInfo:(NSDictionary *)info
{
__weak SFLabel *answersLabel = (SFLabel *)[self.detailTextLabel viewWithTag:1000001];
__weak SFLabel *answersLabel = (SFLabel *)[self.detailTextLabel viewWithTag:QUESTION_LIST_CELL_ANSWER_LABEL];

if ([@"0" isEqualToString:info[@"answersWord"]]) {
answersLabel.backgroundColor = RGBCOLOR(159, 66, 69);
Expand All @@ -96,7 +96,7 @@ - (void)updateQuestionInfo:(NSDictionary *)info
}
[answersLabel sizeToFit];

__weak UIView *tagsContainer = [self.detailTextLabel viewWithTag:1000002];
__weak UIView *tagsContainer = [self.detailTextLabel viewWithTag:QUESTION_LIST_CELL_TAG_CONTAINER];
tagsContainer.left = answersLabel.right + 2.0f;
tagsContainer.width = 200.0f - tagsContainer.left;
tagsContainer.backgroundColor = RGBCOLOR(244, 244, 244);
Expand All @@ -113,7 +113,7 @@ - (void)updateQuestionInfo:(NSDictionary *)info
label.backgroundColor = RGBCOLOR(187, 187, 187);
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.font = [UIFont systemFontOfSize:12.0f];
label.font = [UIFont systemFontOfSize:11.0f];
label.layer.cornerRadius = 2.0f;
}
else {
Expand Down

0 comments on commit 93f1bf9

Please sign in to comment.