gpt4 book ai didi

ios - Unwind Segue 在 iOS 8 中不起作用

转载 作者:IT老高 更新时间:2023-10-28 11:27:00 26 4
gpt4 key购买 nike

我有一个应用程序,在 iOS 7 下运行良好,但在为 iOS 8 构建时,展开转场不起作用。

我创建了一个新项目并添加了一个模态(带有 tableviewcontroller 的导航 Controller )并尝试使用展开模态。不幸的是,它也不起作用。正在展开的方法位于目标 View Controller 中。展开转场是通过 Storyboard (tableviewcontroller 中的导航栏按钮)创建的。当我点击按钮时,什么也没有发生。没有日志输出,模态也没有消失。它似乎也只影响模态序列。 push/popover 正常展开。

有没有人遇到过类似的问题,并且有一个想法我该如何解决?

最佳答案

Apple has FIXED this bug in iOS 8.1

Temporary solutions for iOS 8.0

The unwind segue will not work only in next situation:

View structure: UITabBarController -> UINagivationController -> UIViewController1 -> UIViewController2

Normally (in iOS 7, 8.1), When unwind from UIViewController2 to UIViewController1, it will call viewControllerForUnwindSegueAction in UIViewController1.

However in iOS 8.0 and 8.0.x, it will call viewControllerForUnwindSegueAction in UITabBarController instead of UIViewController1, that is why unwind segue no longer working.

解决方案:通过创建自定义 UITabBarController 覆盖 UITabBarController 中的 viewControllerForUnwindSegueAction 并使用自定义的。 p>

对于 swift

CustomTabBarController.swift

import UIKit

class CustomTabBarController: UITabBarController {

override func viewControllerForUnwindSegueAction(action: Selector, fromViewController: UIViewController, withSender sender: AnyObject?) -> UIViewController? {
var resultVC = self.selectedViewController?.viewControllerForUnwindSegueAction(action, fromViewController: fromViewController, withSender: sender)
return resultVC
}

}

对于老式的 Objective-C

CustomTabBarController.h

#import <UIKit/UIKit.h>

@interface CustomTabBarController : UITabBarController

@end

CustomTabBarController.m

#import "CustomTabBarController.h"

@interface CustomTabBarController ()

@end

@implementation CustomTabBarController

-(UIViewController *)viewControllerForUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController withSender:(id)sender
{
return [self.selectedViewController viewControllerForUnwindSegueAction:action fromViewController:fromViewController withSender:sender];
}

@end

==============================================================================

DO NOT USE ANY SOLUTIONS BELOW THIS POINT (they are out of date and just for reference)

9 月 23 日最新更新

我的新解决方案是推送到嵌入在导航 Controller 中的 View ,并将导航 Controller 配置为在推送时隐藏底部栏(IB 中的复选框)。然后你会看到一个看起来像模态视图的 View ,唯一不同的是推送和弹出的动画。您可以根据需要自定义

更新:下面的解决方案实际上是在标签栏下呈现了模态视图,这会导致进一步的 View 布局问题。

将 segue 类型更改为 Present As Popover 仅适用于 iPhonesiOS8在 iOS7 上您的应用会崩溃

同样,为了解决这个问题,我将 segue 的演示文稿设置为当前上下文(我的应用仅适用于 iphone)。

默认和全屏都不起作用。

enter image description here

关于ios - Unwind Segue 在 iOS 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25654941/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com