加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – IOS 8 SplitViewController iPhone模拟器肖像det

发布时间:2020-12-16 07:10:25 所属栏目:百科 来源:网络整理
导读:这是斯坦福iPhone编程课程的一部分.该程序的目的是浏览tableViewControllers中的照片并将其显示在 ImageViewController中. 原始代码是在iOS 7环境下编写的,因此它有两个适用于iPhone和iPad的故事板.前者使用tabViewController,后者使用splitViewController.
这是斯坦福iPhone编程课程的一部分.该程序的目的是浏览tableViewControllers中的照片并将其显示在 ImageViewController中.

原始代码是在iOS 7环境下编写的,因此它有两个适用于iPhone和iPad的故事板.前者使用tabViewController,后者使用splitViewController.

由于iOS 8允许我们在iPhone和iPad中使用splitViewController,所以我只删除iPhone故事板,并使用iPad作为通用布局.我的故事板布局是这样的:哎呀,我不能在这里发布布局图像,没有足够的声誉. click here to see the storyboard

我设置了两个segues,它们将两个tableViewController与最低的navigationViewController链接到“Show detail”.和Xcode模板“Master-detail application”一样,我将splitViewController设置为委托自己,并将我的detailViewController(ImageViewController)的leftBarButtonItem设置为appDelegate中的displayModeButtonItem.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
    UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
    navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
    splitViewController.delegate = self;
    return YES;
}

问题出在iPhone纵向模式下,“Master”后退按钮不会出现在ImageViewController的左上角.在iPad模式下,一切正常.

我在这里链接我的代码:code for this program.希望有人可以提供帮助.谢谢!

解决方法

我使用了展开segue技术(以编程方式)和ImageViewController上的自定义左栏按钮(即详细视图).

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    // Need a back button to appear when not in split view i.e. iPhone mode
    // Wire up to unwind segue action
    if (!self.splitViewController) {
        UIImage *image = [UIImage imageNamed:@"ImageViewControllerBarBackIndicatorDefault"];
        UIBarButtonItem *btnBack = [[UIBarButtonItem alloc]
                                initWithImage:image
                                style:UIBarButtonItemStylePlain
                                target:self
                                action:@selector(OnClick_btnBack:)];
        self.navigationItem.leftBarButtonItem = btnBack;
    }
}

-(IBAction)OnClick_btnBack:(id)sender {
    [self performSegueWithIdentifier:@"unwind" sender:self];
}

#pragma Unwind Segue

- (BOOL)canPerformUnwindSegueAction:(SEL)action
             fromViewController:(UIViewController *)fromViewController
                     withSender:(id)sender {
    return YES;
}

- (IBAction)unwindFromImageViewController:(UIStoryboardSegue *)unwindSegue {
    [self dismissViewControllerAnimated:YES completion:nil];
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读