【问题标题】:Universal Master-Detail Storyboard help on seguesegue 上的通用主从故事板帮助
【发布时间】:2012-04-18 12:54:08
【问题描述】:

我正在尝试使用 iPhone 和 iPad 故事板制作我的第一个通用应用程序。

我有一个非常简单的应用程序,它在 UITable 上显示一个列表以及单击时项目的详细信息。

它适用于 iPhone,我创建了一个 segue 来推送详细视图,并使用以下代码正常工作:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self performSegueWithIdentifier:@"detail" sender:nil];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"detail"])
    {
        NSIndexPath *selectedIndex = [self.tableView indexPathForSelectedRow];
        // Get reference to the destination view controller
        self.detailViewController = [segue destinationViewController];

        // Pass any objects to the view controller here, like...
        self.detailViewController.detailDict = [myArray objectAtIndex:selectedIndex.row];
    }
}

我不知道这是否有什么不同,但我已将我的 iPad 设置为仅在横向上工作。 无论如何,我怎样才能优化这段代码以在 iPad 故事板上工作?

我已经为 iPad 尝试了不同的 segue,但没有一个能奏效。我得到(gdb)

【问题讨论】:

    标签: iphone objective-c ipad xcode4.2 storyboard


    【解决方案1】:

    我最终得到了这段代码。它适用于 iOS 5 和 6

    #pragma mark - Orientations
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
            return UIInterfaceOrientationIsPortrait(interfaceOrientation);
        else
            return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    

    确保我检查了 Target > Summary > Supported Interface Orientations 上的按钮

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-12
      • 2014-01-23
      • 1970-01-01
      • 2013-06-30
      • 2012-02-15
      • 2014-10-25
      • 2023-03-14
      • 1970-01-01
      相关资源
      最近更新 更多