如何在textview中显示sqlite数据?

时间:2011-09-29 10:18:03

标签: iphone

我的名字是NipinVarma,我想知道我的iphone应用程序中的一些错误。我正在为客户端做一个圣经应用程序,我几乎完成了应用程序的功能,如身份验证,UI等等.sqlite是用于圣经的数据库,我想在textview中显示圣经sql数据库。但我已经用tableview控制器完成了这个,每个经文和genisis都根据我的需要通过数组计数显示在tableview中。我需要的是当我们打开那个页面阅读圣经时,在textview中显示这个。我把我的代码放在tableview中给我正确的输入。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    BibleIphoneAppDelegate *appDelegate = (BibleIphoneAppDelegate *)[[UIApplication sharedApplication] delegate];
    return appDelegate.biblearray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

    }
    cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
    cell.detailTextLabel.numberOfLines = 0;
    cell.detailTextLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:12.0];
    // Set up the cell
    tbl.separatorColor = [UIColor clearColor];
    BibleIphoneAppDelegate *appDelegate = (BibleIphoneAppDelegate *)[[UIApplication sharedApplication] delegate];
    bible *jesus = (bible *)[appDelegate.biblearray objectAtIndex:indexPath.row];

    [cell setText:jesus.chapterNo];
    cell.detailTextLabel.text = jesus.verseNumber;
    cell.font = [UIFont systemFontOfSize:9.0];
    return cell;

请帮我这样做。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

使用UITableViewDelegate的didSelectRowAtIndexPath:

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
    NSInteger row = [indexPath row];
    [self pushChildViewControllerForRow:row animated:YES];
}

然后在pushChildViewControllerForRow中,您可以执行以下操作:

-(void)pushChildViewControllerForRow:(NSUInteger)row animated:(BOOL)flag {
     if (chapterViewController==nil) {
            self.chapterViewController = [[ChapterViewController alloc] initWithNibName:@"ChapterViewController" bundle:nil];
        [navigationController pushViewController:chapterViewController animated:flag];
        // and here you will need to populate chapterViewController with data extracted from your sqlite database
}

ChapterViewController可能类似于:

@interface ChapterViewController : UIViewController <UITextViewDelegate> {
    IBOutlet UITextView *textView;
}
@property (nonatomic, retain) UITextView *textView;
-(void)backButtonPressed:(id)sender;
@end

希望你有个主意。

相关问题