ViewController出现时搜索字符串

时间:2013-10-16 11:36:09

标签: javascript ios objective-c uiwebview

我有UIWebView用于显示文章(HTML页面)。然后我从文章中选择并选择文本和articleId保存到数据库。因为稍后我需要显示包含articleId的所选文本。我得到这些保存的值另一个viewcontroller 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保存的行

0 个答案:

没有答案