Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  2. NSString *identifier = @"FeedCell";
  3. FeedDetailCell *cell = (FeedDetailCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
  4. if (cell==nil) {
  5. cell = (FeedDetailCell*)[[[NSBundle mainBundle] loadNibNamed:@"FeedDetail" owner:nil options:nil] objectAtIndex:0];
  6. }
  7. [tableView setSeparatorColor:[UIColor grayColor]];
  8. switch (indexPath.section) {
  9. case 0:
  10. if (indexPath.row == 0) {
  11. cell.nameLabel.text = @"Telephone";
  12. [cell.detailLabel setText:[_feedDictionary valueForKey:@"mobile"]];
  13. }
  14. else {
  15. cell.nameLabel.text = @"Mobile";
  16. [cell.detailLabel setText:[_feedDictionary valueForKey:@"iPhone"]];
  17. }
  18. break;
  19. case 1:
  20. cell.nameLabel.text = @"E-mail";
  21. [cell.detailLabel setText:[_feedDictionary valueForKey:@"Email"]];
  22. break;
  23. case 2:
  24. cell.nameLabel.text = @"address";
  25. [cell.detailLabel setText:[_feedDictionary valueForKey:@"address"]];
  26. CGSize size = [[_feedDictionary valueForKey:@"address"] sizeWithFont:[UIFont systemFontOfSize:14.0]
  27. constrainedToSize:CGSizeMake(200.0, 400.0) lineBreakMode:UILineBreakModeWordWrap];
  28. CGRect frm = cell.detailLabel.frame;
  29. frm.size.height = size.height;
  30. [cell.detailLabel setFrame:frm];
  31. default:
  32. break;
  33. }
  34. return cell;
  35. }
  36.  
  37.  
  38. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  39. if (indexPath.section == 2) {
  40. NSString *address = [_feedDictionary valueForKey:@"address"];
  41. CGSize recommendedSize = [address sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(320, INT_MAX)];
  42. return 44 + recommendedSize.height;
  43. }
  44. else {
  45. return 44;
  46. }
  47. }
  48.  
  49. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath;
  50.  
  51. @interface PartnerCell : UITableViewCell {
  52. UILabel *user_name,*lbldate,*lbldesc;
  53. LoadImage *img_trade;
  54. UIImageView *partnerimage;
  55. }
  56. @property (nonatomic, strong) UILabel *user_name,*lbldate,*lbldesc;
  57. @property (nonatomic, strong) LoadImage *img_trade;
  58. @property (nonatomic, strong) UIImageView *partnerimage;
  59. @end
  60.  
  61. @implementation PartnerCell
  62. @synthesize user_name,lbldate,lbldesc;
  63. @synthesize img_trade,partnerimage;
  64.  
  65. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  66. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  67.  
  68. [self setSelectionStyle:UITableViewCellSelectionStyleNone];
  69.  
  70. user_name = [[UILabel alloc] initWithFrame:CGRectMake(75,8,200,15)];
  71. [user_name setBackgroundColor:[UIColor clearColor]];
  72. user_name.font = [UIFont fontWithName:@"Arial-BoldMT" size:15];
  73. [user_name setTextColor:[UIColor colorWithRed:70/255.00f green:70/255.00f blue:70/255.00f alpha:1.0]];
  74. [self addSubview:user_name];
  75.  
  76. lbldate = [[UILabel alloc] initWithFrame:CGRectMake(75,28,200,15)];
  77. [lbldate setBackgroundColor:[UIColor clearColor]];
  78. lbldate.font = [UIFont fontWithName:@"Arial" size:14];
  79. [lbldate setTextColor:[UIColor darkGrayColor]];
  80. [self addSubview:lbldate];
  81.  
  82.  
  83. lbldesc = [[UILabel alloc] initWithFrame:CGRectMake(75,45,170,35)];
  84. [lbldesc setBackgroundColor:[UIColor clearColor]];
  85. lbldesc.font = [UIFont fontWithName:@"Arial" size:13];
  86. lbldesc.numberOfLines = 2;
  87. [lbldesc setTextColor:[UIColor darkGrayColor]];
  88. [self addSubview:lbldesc];
  89.  
  90.  
  91. img_trade = [[LoadImage alloc] initWithFrame:CGRectMake(3, 5, 54, 55)];
  92. img_trade.userInteractionEnabled = YES;
  93. [self addSubview:img_trade];
  94.  
  95.  
  96.  
  97. }
  98. return self;
  99. }
  100.  
  101. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  102. {
  103.  
  104. NSString *CellIdentifier = [NSString stringWithFormat:@"%@",[[Partarray objectAtIndex:indexPath.row-1] valueForKey:@"part_id"]];
  105. cell = (PartnerCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  106. cell=nil;
  107. if (cell == nil)
  108. {
  109. cell = [[PartnerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  110. //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[Partarray objectAtIndex:indexPath.row]] autorelease];
  111. cell.selectionStyle= UITableViewCellSelectionStyleGray;
  112. cell.backgroundColor = [UIColor clearColor];
  113. cell.user_name.frame=CGRectMake(75,8,340,15);
  114. cell.lbldate.frame=CGRectMake(75,28,340,15);
  115. cell.lbldesc.frame=CGRectMake(75,45,340,35);
  116.  
  117.  
  118. cell.user_name.text = @"user name";
  119. cell.lbldate.text = @"date";
  120. cell.lbldesc.text = @"description";
  121.  
  122.  
  123.  
  124. }
  125. return cell;
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement