我有 UIWebView 用于显示文章(HTML 页面)。然后我从文章中选择并通过选择文本和 articleId 保存到数据库。因为稍后我需要显示选定的文本,包括articleId。我在另一个视图控制器 VC1 中获取这些保存的值。我正在从 VC 中选择和保存文本。
VC1:
- (void)tableView:(UITableView *)tableView1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"index path %d", indexPath.row);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"ohs.sqlite"];
NSLog(@"filepath %@",path);
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
const char *sql = [[NSString stringWithFormat:@"SELECT art_title, art_details FROM articles where art_id = '%@'",[artIdArray objectAtIndex:indexPath.row]] cStringUsingEncoding:NSUTF8StringEncoding];
NSLog(@"sql table is %s",sql);
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
// We "step" through the results - once for each row.
while (sqlite3_step(statement) == SQLITE_ROW) {
content = [[NSString alloc] initWithUTF8String:
(const char *) sqlite3_column_text(statement, 1)];
NSLog(@"content is %@",content);
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
const char *sql = [[NSString stringWithFormat:@"SELECT notes, notes_id FROM note where notes = '%@'",[mArray objectAtIndex:indexPath.row]] cStringUsingEncoding:NSUTF8StringEncoding];
NSLog(@"getmainsql1 is %s",sql);
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
// We "step" through the results - once for each row.
while (sqlite3_step(statement) == SQLITE_ROW) {
content1 = [[NSString alloc] initWithUTF8String:
(const char *) sqlite3_column_text(statement, 0)];
NSLog(@"content1 is %@",content1);
}
}
}
}
}
}
VC *det = [[VC alloc] init];
NSString *decodeString = [self htmlEntityDecode:content];
[content release];
//UIWebView *wbCont = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
//[wbCont loadHTMLString:decodeString baseURL:nil];
det.webString = decodeString;
//[det.view addSubview:wbCont];
[self.navigationController pushViewController:det animated:YES];
}
在这里我需要指出或转到 mArray 值行。但是当显示 VC 时,它会显示文章,但它会从头开始显示。我需要去 mArray 保存的行