Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Custom Cell UIImage not showing in UITableVIew - iOS 5

idny99idny99 Posts: 12Registered Users
Im am trying to display a UIImage (inside Custom Cell) inside a UITableView.
The image is currently in the Resources folder with the name: newimage.jpg

Here is the CustomCell.h/m

#import <UIKit/UIKit.h>

@interface ResultsCustomCell : UITableViewCell
{
IBOutlet UILabel *customLabel;
IBOutlet UITextView *snippet;
IBOutlet UIImage *newsImage;
}

@property (nonatomic, retain) IBOutlet UILabel *customLabel;
@property (nonatomic, retain) IBOutlet UITextView *snippet;
@property (nonatomic, retain) IBOutlet UIImage *newsImage;

@end

#import \"ResultsCustomCell.h\"

@implementation ResultsCustomCell

@synthesize customLabel, snippet, newsImage;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

@end


Here is my UITableView method for populating the cells:

#import \"ResultsCustomCell.h\"

// Populate TableView cells with contents of array.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @\"CellIdentifier\";

ResultsCustomCell *myCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NewsArticle *n = (NewsArticle *)[appDelegate.articles objectAtIndex:indexPath.row];

myCell.customLabel.text =n.newsHeading;
myCell.snippet.text = n.articleText;

myCell.newsImage = [UIImage imageNamed:@\"newimage.jpg\"];

return myCell;
}



both the customLabel.text and the snippet.text display correctly, however the image does not show and a blank white space is there instead.

What am i doing wrong? How can i get the UIImage to display correctly?
Post edited by idny99 on

Replies

Sign In or Register to comment.