Reputation: 91
I am trying to do something similar to twitter or Facebook.
Upvotes: 9
Views: 20203
Reputation: 39201
Swift version:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel.text = "I'm a UITableViewCell!";
cell.textLabel.textColor = UIColor.whiteColor()
cell.imageView.image = UIImage(named: "MyReallyCoolImage.png")
return cell;
}
Upvotes: 0
Reputation: 930
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString* CellIdentifier = @"Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[[UITableViewCell alloc] UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.text = @"I'm a UITableViewCell!";
cell.imageView.image = [UIImage imageNamed:@"MyReallyCoolImage.png"];
return cell;
}
Credit to Thomas Moore
Upvotes: 18
Reputation: 4634
Well, to add an image to a table cell, you would add a UIImage to the image property of a subtitle UITableViewCell or your own custom Cell. I would read the doc on Customizing UITableViewCells at developer.apple.com.
Upvotes: 1