2011-07-04 11 views
0

xcodeでtableviewのデフォルトのアプリケーションを作成しました。ios tableviewメインビューに戻る

しかし:AppDelegateで

は、ボタンの押しのテーブルビューをロードする機能を追加します。

self.window.rootViewController = self.navigationController;

うまく動作します。

でRootViewController aはデータを含む配列を作成し、それをtableviewに渡します。これも正常に動作します。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UIAlertView *alert = [[UIAlertView alloc] 
          initWithTitle:@"iPad Selected"       
          message:[NSString stringWithFormat:@"iPad %d", indexPath.row]      
          delegate:self  
          cancelButtonTitle:@"OK"   
          otherButtonTitles:nil]; 
    [alert show]; 
    [alert release]; 
} 

enter image description here

私は戻っMAINVIEWに行くと、表からテキストとボタンのLableを設定し、セルの上に押して文句を言いません。また、ID(行インデックス)を変数に保存することもできます。

ヘルプが必要です。

+0

あなたが試してみましたが、どこが立ち往生している何をやりたい、実際に多くのものを詳しく説明してください? –

+0

あなたのメインビュー自体はrootviewだと思うので、アプリケーションが起動するルートビューです。どこに戻りたいですか? – iMOBDEV

+0

あなたのメインビューですか? –

答えて

0

View2viewControllerという別のviewcontrollerを追加してください。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    View2viewController *view2 = [[ View2viewController alloc] initWithNibName:@"View2viewController" bundle:nil]; 
     [self.navigationController pushViewController:view2 animated:YES]; 
       [view2 release]; 
} 

Check this tutorial it will help you to learn

関連する問題