开发者

Display image from MySQL database in a UITableView iPhone

I have some image data stored in BLOB format in MySQL database, I fetch the string and integer data but for image it does not display. i also tried using a UIImageView 开发者_如何学编程but it doesn't work.

Can some one please post some code to display the image data in a UITableView. NSData-->UIImage-->image display.

Thanks


Given a NSData object data where the data is a UIImage supported image type (PNG, JPG, ...)

/* These two are what I assume you start with */
char *rawData = [self getRawDataFromDB];
int rawDataLength = [self getLengthOfRawData];

/* To convert that to an image... */
UIImage *image = [UIImage imageWithData:[NSData dataWithBytes:rawData length:rawDataLength]];

Once you have the image, then add to your UITableViewDataSource's tableView:cellForRowAtIndexPath:

[[cell imageView] setImage: image];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜