2

AppDelegateで を作成するDetailViewと、その上にがloginView表示されます ( UIModalPresentationFullScreen)。ログイン後、終了しますloginView

DetailViewtableViewセル/行を選択して2番目を押すと、とがありますdetailView

私がこれまでに行ったこと: In AppDelegateI ask for UI_USER_INTERFACE_IDIOM()and when idiom is iPadi create a splitView:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    FirstDetailViewController* fdvc = [[FirstDetailViewController alloc] initWithNibName:@"FirstDetailViewController" bundle:nil];
    SecondDetailViewController* sdvc = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailViewController" bundle:nil];

    UINavigationController* fdvcNavigationController = [[UINavigationController alloc] initWithRootViewController:fdvc];
    UINavigationController* sdvcNavigationController = [[UINavigationController alloc] initWithRootViewController:sdvc];

    splitViewController = [[UISplitViewController alloc] init];
    splitViewController.viewControllers = [NSArray arrayWithObjects:fdvcNavigationController, sdvcNavigationController, nil];

ログイン後、LoginViewが閉じられ、UISplitViewControllerが表示されます。最初はDetailView左側 (マスター) です。だからここですべてがうまくいった。

ここで、FirstDetailViewController.m に移動し、didSelectRowAtIndexPathを検索します。これは、「iPhone バージョン」でSecondDetailViewControllerへのpushViewを見つけるためです。

そして、ここで私は立ち往生しています。SplitView私はいくつかのチュートリアルを試し、他の人の問題を読みsplitviewました.

しかし、私はプログラミング/ iOS全般に不慣れで、すべてのツールを知らないため、私の問題はある種の「基本」だと思います。

どんな助けでも大歓迎です。

4

1 に答える 1

3

テーブル ビューとテーブル内のアイテムの他の種類の「表示」ビューを使用してアプリを作成する場合、両方のデバイスで動作するようにこれを行います。

// In App Delegate...
-(BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Create views
    MyTableViewController* myTable = [[MyTableViewController alloc] init];
    MyDetailViewController* myDetail = [[MyDetailViewController alloc] init];
    UINavigationController* tableNav = [[UINavigationController alloc] initWithRootViewController:myTable];
    UINavigationController* detailNav = [[UINavigationController alloc] initWithRootViewController:myDetail];

    // Check device type
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {

        // Use a split view
        UISplitViewController* splitView = [[UISplitViewController alloc] init];
        split.viewControllers = @[tableNav, detailNav];
        self.window.rootViewController = split;

    } else {

        // Use a single view for iPhone
        self.window.rootViewController = tableNav;

    }

}

.

// In table view
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // Check device type
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {

        // Tell the already visible detail view to load something
        MyData* data = ...; \\ Get your thing to display however you want
        [[NSNotificationCenter defaultCenter] postNotificationName:@"DisplayMyData" object:data];

    } else {

        // No detail controller exists yet, so create it
        MyDetailViewController* myDetail = [[MyDetailViewController alloc] init];
        [self.navigationController pushViewController:myDetail animated:YES];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"DisplayMyData" object:data];

    }

}

.

// In detail view
-(void) viewDidLoad {
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(displayData:) name:@"DisplayMyData" object:nil];

}

-(void) displayData:(NSNotification*)notify {

    MyData* data = (MyData*) notify.object;

    ... // Display however...

}
于 2013-04-02T13:10:52.183 に答える