【发布时间】:2013-05-24 11:52:26
【问题描述】:
你好,
我被卡在了最后一部分,请帮助我。
其中有三个视图,第一个一个,用于书籍列表(在UITableView中), second 是 chapters(在 UITableView 中),last 是 content,其中是文本格式(在 UITextView 中)。
到第二个视图它工作得很好。问题是,当我在第二个视图中选择任何章节时,第三个视图中的文本视图 什么都不显示。但是在输出中显示数字序列。
从数据库中获取数据并显示到 UITextView 中的代码。
NSMutableString *mStr = [NSMutableString stringWithFormat:@"select content from content where name = \"%@\" and chapterno = %@",chapName,chapNo];
const char *sql =(char *)[mStr UTF8String];
sqlite3_stmt *sqlStmt;
if(sqlite3_prepare(dbContent, sql, -1, &sqlStmt, NULL)!=SQLITE_OK)
{
NSLog(@"prob with prepare statement: %s",sqlite3_errmsg(dbContent));
}
else
{
while (sqlite3_step(sqlStmt)==SQLITE_ROW) {
len = sqlite3_column_bytes(sqlStmt, 0);
NSData *cData = [[NSData alloc]initWithBytes:sqlite3_column_blob(sqlStmt, 0) length:len];
NSString *nstr = [NSString stringWithUTF8String:[cData bytes]];
myTextView.text = nstr;
}
在上面的 chapName 来自 first view 并且 chapNo 在 second view 中被选中。 p>
内容表如下:
id bookid name chapterno content
1 1 abc 1 BLOB(size:4217)
2 1 abc 2 BLOB(size:3193)
3 1 abc 3 BLOB(size:3501)
O/p 是这样的一长串数字。
<0d0a3120 496e2074 68652062 6567696e 6e696e67 20476f64 20637265 61746564 20746865 20686561 76656e20 616e6420 74686520 65617274 682e0d0a...>
在这里,我需要在文本视图中显示文本内容。我在这里缺少什么?
【问题讨论】:
标签: iphone uitableview sqlite uitextview