Note that there are some explanatory texts on larger screens.

plurals
  1. PODoing customization for a cell but dont work
    text
    copied!<p>My purpose is to customize a cell for a row of my table view. So I am doing :</p> <pre><code>MyClass.m 1 .- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{ 3 . NSLog(@"section %d:row %d",indexPath.section, indexPath.row); 4 . static NSString *CellIdentifier = @"reusedCell"; 5 . DetailCell *cell = (DetailCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 6 . cell.backgroundColor = [UIColor clearColor]; 7 . // Customize the cell of each row from table 8 . **if ( cell == nil ) { 9 . cell = [[DetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 10. }** 11. return cell; 12.} </code></pre> <p>my DetailCell class is</p> <pre><code> 1.- (DetailCell*)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 2. if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]){ 3. itemImg = [[UIImageView alloc] initWithFrame:CGRectMake(20 , 20, 50 , 70)]; 4 itemName = [[UILabel alloc] initWithFrame:CGRectMake(100, 0 , 100 , 50)]; 5. itemDesp = [[UILabel alloc] initWithFrame:CGRectMake(100, 40, 1000, 20)]; 6 itemSize = [[UILabel alloc] initWithFrame:CGRectMake(100, 60, 100 , 20)]; 7 itemPrice = [[UILabel alloc] initWithFrame:CGRectMake(200, 60, 100 , 20)]; } 8. [itemImg setImage:[UIImage imageNamed:@"large/dresses/02/71EU6.png"]] ; 9. itemName.text = @"Dresses"; 10. itemDesp.text = @"Description"; 11. itemSize.text = @"S"; 12. itemPrice.text = @"$99"; 13. itemSize.textColor = [UIColor purpleColor]; 14. [self.contentView addSubview:itemImg]; 15. [self.contentView addSubview:itemName]; 16. [self.contentView addSubview:itemDesp]; 17. [self.contentView addSubview:itemSize]; 18. [self.contentView addSubview:itemPrice]; 19. return self; 20. } </code></pre> <p>To display an img or text on the row of my table, I set img + text on UIImageView and Label within <strong>DetailCell</strong> ( line 8---> line 13 at DetailCell). However, when I went through some readings and I realized that people use a class such as DetailCell to create a frame + add properties for UIImageView + Label. Finally, they will display an image or text on cell within <strong>myClass.m</strong>. It is confusing me because should we set img for UIImageView at <strong>MyClass.m</strong> or <strong>DetailCell.m</strong>. Please advice me about this issue. Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload