我有一个应用程序,它在iOS 7下运行良好,但当为iOS 8构建时,放松段不起作用.

我创建了一个新项目,添加了一个模式(navigationcontroller和tableviewcontroller),并try 使用一个展开模式.不幸的是,它也不起作用.要展开到的方法位于"设计视图"控制器中.展开序列是通过故事板(tableviewcontroller中的导航栏按钮)创建的.当我点击该按钮时,什么也没有发生.没有日志(log)输出,模式也不会消失.它似乎也只影响模态序列.push/popover正常展开.

有没有人有过类似的问题,并且知道我如何解决它?

推荐答案

Apple has FIXED this bug in iOS 8.1

Temporary solutions for iOS 8.0

只有在下一种情况下,放松阶段才会起作用:

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

通常(在iOS 7、8.1中),当从UIViewController2放松到UIViewController1时,它会在UIViewController1中呼叫viewControllerForUnwindSegueAction.

但是在iOS 8.0和8.0中.x、 它将在UITabBarController中调用viewControllerForUnwindSegueAction而不是UIViewController1,这就是为什么unwind segue不再工作的原因.

Solution:通过创建自定义UITabBarController并使用自定义UITabBarController来覆盖UITabBarController中的viewControllerForUnwindSegueAction.

For Swift

CustomTabBarController.敏捷的

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
    }

}

For old school 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)

Latest update on Sep 23

My new solution is pushing to a view that embedded in a navigation controller, and config that navigation controller to hide bottom bar on push(a tick box in IB). Then you will have a view looks like a modal view, the only different is the animate of pushing and popping. You can custom if you want

Updated:下面的解决方案实际上是tab bar下的modal view,这将导致进一步的视图布局问题.

将segue类型更改为Present As Popover将仅适用于iPhoneson iOS7 your app will crashiOS8.

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

默认和全屏将不起作用.

在此处输入图像描述

Objective-c相关问答推荐

如何限制 UITextField 中的特殊字符(点和下划线除外)?

iOS:警告try 呈现其视图不在窗口层次 struct 中的 ViewController

如何通过仅更改高度而不更改宽度来调整 UILabel 的大小?

iphone 的 UIPopoverController 不工作?

将 NSNumber 转换为 NSDecimalNumber

重复符号 _OBJC_METACLASS_$_ClassName

iOS7过度导航栏按钮填充

iOS框架改变一个属性(例如宽度)

在 Xcode 5 中运行代码覆盖时出现数十个profiling:invalid arc tag

UILabel 的角半径属性在 iOS 7.1 中不起作用

Objective-C - 何时使用touch

判断 NSString 是否只是由空格组成

Objective-C 中的 super 到底是什么?

Select 时 UITableViewCell 复选标记更改

如何在 UIAlertController 中添加 textField?

UILabel 根据要显示的文本自动调整大小

在 UITableView 的 iOS 文档目录中列出保存的文件?

字符串常量和字符串文字有什么区别?

CMTime 秒输出

如何在 iOS 中创建自定义 UIActivity?