Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"Cell";
- //NotificationCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil)
- {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- }
- for(UIView *view in cell.contentView.subviews)
- {
- [view removeFromSuperview];
- }
- noteBody = [Noifications objectAtIndex:indexPath.row];
- yPosition = 10;
- UILabel *Title = [[UILabel alloc]initWithFrame:CGRectMake(10, yPosition, self.view.frame.size.width-20, 0)];
- Title.text = [noteBody objectForKey:@"subject"];
- Title.font = [UIFont boldSystemFontOfSize:20];
- Title.numberOfLines = 0;
- [Title sizeToFit];
- yPosition += Title.frame.size.height;
- [cell.contentView addSubview:Title];
- UILabel *Date = [[UILabel alloc]initWithFrame:CGRectMake(10, yPosition, self.view.frame.size.width-20, 25)];
- Date.text = [noteBody objectForKey:@"datesent"];
- Date.numberOfLines = 0;
- Date.textColor = [UIColor grayColor];
- [Title sizeToFit];
- yPosition += Date.frame.size.height;
- [cell.contentView addSubview:Date];
- UILabel *Body = [[UILabel alloc]initWithFrame:CGRectMake(10, yPosition, self.view.frame.size.width-20, 0)];
- Body.text = [noteBody objectForKey:@"body"];
- Body.numberOfLines = 0;
- [Body sizeToFit];
- yPosition += Body.frame.size.height;
- [cell.contentView addSubview:Body];
- return cell;
- }
- #pragma mark - Table view delegate
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- noteBodyCellHeight = [Noifications objectAtIndex:indexPath.row];
- NSString *title = [noteBodyCellHeight objectForKey:@"subject"];
- NSString *date = [noteBodyCellHeight objectForKey:@"datesent"];
- NSString *body = [noteBodyCellHeight objectForKey:@"body"];
- CGRect frame = [UIScreen mainScreen].bounds;
- CGFloat width = frame.size.width;
- int section = indexPath.section;
- CGSize title_size = {0, 0};
- CGSize date_size = {0, 0};
- CGSize body_size = {0, 0};
- if (title && [title isEqualToString:@""] == NO ) {
- title_size = [title sizeWithFont:[UIFont systemFontOfSize:22.0]
- constrainedToSize:CGSizeMake(width, 4000)
- lineBreakMode:UILineBreakModeWordWrap];
- }
- if (date && [date isEqualToString:@""] == NO ) {
- date_size = [date sizeWithFont:[UIFont systemFontOfSize:18.0]
- constrainedToSize:CGSizeMake(width, 4000)
- lineBreakMode:UILineBreakModeWordWrap];
- }
- if (body && [body isEqualToString:@""] == NO ) {
- body_size = [body sizeWithFont:[UIFont systemFontOfSize:18.0]
- constrainedToSize:CGSizeMake(width, 4000)
- lineBreakMode:UILineBreakModeWordWrap];
- }
- CGFloat title_height = title_size.height;
- CGFloat date_height = date_size.height;
- CGFloat body_height = body_size.height;
- //CGFloat content_size = Body.frame.size.height + Title.frame.size.height + Date.frame.size.height;
- CGFloat content_size = title_height + date_height + body_height +25;
- CGFloat height;
- switch ( section ) {
- case 0:
- height = content_size;
- break;
- //Just in case
- default:
- height = 44.0;
- break;
- }
- return height;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement