Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've had exactly the same problem, except half way through implementation we decided to scrap the design and went for custom tableview cells instead. Our original design was meant to look like a notepad, with cells on each line.</p> <p>Subclassing a UITableViewCell might seem like a difficult task but its worth it if you will need to customise the cell in the future and seems like it will do what you are requesting. I can post the code for you from my project if you are interested, However, be aware that you will not have the background on the UITableView itself, only on the cells.</p> <p>EDIT: Posting the code related to creation of custom UITableViewCell: My cell is called HotOffersCell, This is HotOffersCell.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface HotOffersCell : UITableViewCell { IBOutlet UILabel *mainLabel; IBOutlet UILabel *subLabel; IBOutlet UILabel *price; IBOutlet UIImageView *imageView; } @property (nonatomic, retain) UILabel *mainLabel; @property (nonatomic, retain) UILabel *subLabel; @property (nonatomic, retain) UILabel *price; @property (nonatomic, retain) UIImageView *imageView; @end </code></pre> <p>HotOffersCell.m is very plain, just sysnthesize for all the properties, nothing else Then in the TableView method of your table view controller:</p> <pre><code>// Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"HotOffersCell"; HotOffersCell *cell = (HotOffersCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"HotOffersCell" owner:nil options:nil]; for (id currentObject in topLevelObjects) { if ([currentObject isKindOfClass:[UITableViewCell class]]) { cell = (HotOffersCell *) currentObject; break; } } } NewsItem *newsItem = [newsList objectAtIndex:indexPath.row]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"d MMM YY"]; NSString *date = [formatter stringFromDate:newsItem.departure_date]; if (indexPath.row % 2 == 0) { cell.contentView.backgroundColor = [UIColor colorWithWhite:230.0/255 alpha:1]; // Match Colour } else { cell.contentView.backgroundColor = [UIColor colorWithWhite:242.0/255 alpha:1]; // Match Colour } cell.mainLabel.text = newsItem.destination; cell.subLabel.text = [[NSString alloc] initWithFormat:@"%@ - %@ nights", date, newsItem.nights]; if ([self.navigationController.title isEqualToString:@"Top 20"]) { cell.price.text = newsItem.price_inside; } else { cell.price.text = newsItem.price_balcony; } cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png", newsItem.cruise_line]]; [formatter release]; return cell; } </code></pre> <p>I also have a HotOffersCell.xib, This file contains a UITableViewCell and no view, i've linked all the relevant labels around and nothing more, It provides a nice graphical way to edit the placements on the label without changes in code, I even let my brother modify this one =)</p> <p>I hope this helps</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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