1

シンプルなuitableviewベースのメニューを実装する方法について少し混乱しています.Kayakアプリのようなものhttp://www.sendspace.com/file/igv31p 私のストーリーボードは次のようになります:詳細ビュー コントローラー。マスター ビュー コントローラーには、テーブル ビューがあります。Products、Stores、Packages、Finances の 4 つのセルを動的に入力しました。私がやりたいのは、子uiviewcontrollerになる子uiviewcontrollerを表示することだけです。このようなもの: 製品 --> 特定の機能を備えた UiViewController ストア --> 特定の機能を備えたその他の UIViewControlelr ... など。

didselectrowatindex メソッドを作成し、メソッドの下のコードのように pushViewController で何かをしようとしましたが、うまくいきません。

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

[tableView deselectRowAtIndexPath:indexPath animated:YES];
StoresViewController *storeView = [[StoresViewController alloc]init];
switch (indexPath.section) {
    case 0:
        switch (indexPath.row) {
            case 0:
            {

            NSLog(@"Products");

            }
                break;
            case 1:{

                [self.navigationController pushViewController:storeView animated:YES];
                NSLog(@"Stores");

            }
                break;
            case 2:{
                NSLog(@"Packages");
            }
                break;
            case 3:{
                NSLog(@"Finances");

            }
                break;
        }
        break;

    default:
        break;
}

誰かがそれを理解するのを手伝ってくれれば幸いです。この質問が以前に尋ねられた場合は、場所を教えてください:) よろしくお願いします

Kayak アプリのようなもの http://www.sendspace.com/file/igv31p

4

2 に答える 2

1

このコードを置き換えるだけです..

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

[tableView deselectRowAtIndexPath:indexPath animated:YES];


switch (indexPath.section) {
    case 0:
        switch (indexPath.row) {
            case 0:
            {
                NSLog(@"Products");
            }
                break;
            case 1:
            {
                UINavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"StoresViewController"];

                [self presentViewController:navigationController animated:YES completion:nil];
                NSLog(@"Stores");
            }
                break;
            case 2:
            {
                NSLog(@"Packages");
            }
                break;
            case 3:
            {
                NSLog(@"Finances");

                break;
            }
                break;

            default:
                break;
        }
}
于 2013-10-04T12:49:44.137 に答える
0
StoresViewController *storeView = [[StoresViewController alloc]initWithNibName:@"StoresViewController" bundle:nil];

オブジェクトを作成するときにペン先を渡すだけです。

于 2013-10-04T12:33:20.310 に答える