2011-09-29 132 views
0

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

- (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; 

请帮我做到这一点。 在此先感谢。

回答

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 

希望你有一个想法。

+0

但先生我不想要任何表格查看功能,只是想打开一个页面时在文本视图中显示它。 – ICoder

+0

@Nipinvarma,当用户选择他/她想要打开哪个页面时,他/她会在你的桌子上按下原始。然后didSelectRowAtIndexPath被调用。最后加载ChapterViewController,将其推入导航堆栈并使用页面的数据填充它。 ChapterViewController只不过是你想要的UITextView。 –

+0

但实际功能是当用户正确注册时,它会自动导航通过这个圣经页面,我们希望它显示在textview.it应该在viewdidload方法。 – ICoder

相关问题