2011-06-24 9 views
0

現在のアプリケーションは、詳細ビューを選択したときにテーブル行からのタブを使用したナビゲーションとその間のテーブルビューで構成されます。私が抱えている問題は、詳細ビューにプッシュし、Webビューでhtmlファイルを読み込む行を選択するときです。しかし、前にナビゲートして別の行を選択すると、前の選択から同じHTMLがロードされます。関連性を維持するのは、ナビゲーションタイトルバーのタイトルだけです。テーブルビューからプッシュするとウェブビューが更新されない

これは私の苦労したメモリ管理です(私はObjCに新しく1週間しかいません)か、ステップを逃しましたか?私はNSString * navDate = self.titleをつかんだと思う。私の問題です。他のすべては基本的には別の方法で動作します。とにかく、優しく、ありがとう。 :あなたがATextControllerのインスタンスを保持し、それを再利用しているので、$

表のセル

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *CellID = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID]; 
if(cell == nil){ 
    cell = [[UITableViewCell alloc] 
      initWithStyle:UITableViewCellStyleDefault 
      reuseIdentifier:CellID]; 
} 
cell.textLabel.font = [UIFont systemFontOfSize:15]; 
cell.textLabel.text = [self.dateList objectAtIndex: [indexPath row]]; 
return cell; 
} 

行プッシュ

(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
NSInteger row = [indexPath row]; 
if(self.aTextController == nil){ 
    ATextController *aTextDetail = [[ATextController alloc] initWithNibName:@"ArchiveData" bundle:nil]; 
    self.aTextController = aTextDetail; 
    [aTextDetail release]; 
} 
aTextController.title = [NSString stringWithFormat:@"%@", [dateList objectAtIndex:row]]; 
SLESDAppDelegate *delegate = (SLESDAppDelegate *)[[UIApplication sharedApplication] delegate]; 
[delegate.navigationController pushViewController:aTextController animated:YES]; 
} 

DetailView

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
NSString *navDate = self.title; 
NSString *null = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@", navDate] ofType:@"html"]; 
if(null != nil){ 
    [webArchView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@", navDate] ofType:@"html"]isDirectory:NO]]]; } 
else { 
    [webArchView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]isDirectory:NO]]]; 
} 
} 

答えて

0

、あなたが実行する必要があります次のスニペットでviewWillAppear: -

なぜなら、viewDidLoadは、ビューコントローラがそのビューをロードするときに一度呼び出されるからです。画面が表示されるたびにviewWillAppear:が呼び出されます。

+0

ありがとうございました。私はこれを念頭に置いておきます。 – xTHENKx