您好我是能够通过使用下面的代码将图像存储到数据库.......问题在iphone从数据库中读取图像
-(void)insertimages: (NSData *)image
{
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK)
{
NSUInteger len = [image length];
NSLog(@"data size is %d", len);
sqlStatement="insert into messages values(10,?)";
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
//sqlite3_bind_int(compiledStatement, 1, -1);
//sqlite3_bind_blob(updateStmt, 3, [imgData bytes], [imgData length], NULL);
sqlite3_bind_blob(compiledStatement, 1, [image bytes], [image length], SQLITE_TRANSIENT);
//sqlite3_bind_text(compiledStatement, 1, [SMSBody UTF8String],-1,SQLITE_STATIC);
if(sqlite3_step(compiledStatement) == SQLITE_DONE)
{
sqlite3_finalize(compiledStatement);
}
}
sqlite3_close(database);
}
}
,但现在我的问题是我不能够从数据库检索图像,并显示它在uiimageview ...
con任何人请帮助我如何做到这一点。
嗨,一个很好,但我不存储图像的网址。直接保存在数据库中的图像,并希望检索它... – user564963 2011-03-05 10:12:25
@ user564963-嗨,PLZ仔细看看我没有检索URL字符串,我检索URL对象中的图像数据,并将其传递给NSData对象。 – 2011-03-05 10:22:21