2011-09-29 64 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

相關問題