小编Ken*_* Ko的帖子

在iOS 8中使用presentViewController:animated:completion时,presentsViewController为nil

想知道最近是否有其他人遇到过这个问题......

对于我的一个视图控制器,仅在iOS 8上,在调用之后presentViewController:animated:completion:,呈现的视图控制器self.presentingController为零.它在iOS7上很好,也不会在另一个视图控制器上发生.

文件说,它应该被设置,只要提交视图控制器是模态呈现.鉴于它适用于iOS 7,这可能是iOS 8的错误吗?

我已经能够使用视图容器包含方法来解决它,但如果有人之前已经看过它并且知道触发此行为的根本原因,那将会很好.

谢谢

uiviewcontroller ios ios8

32
推荐指数
1
解决办法
8592
查看次数

如何捕获Swift崩溃并进行一些日志记录

在Objective-C中,NSSetUncaughtExceptionHandler可以注册一些功能来做最后一分钟的异常日志记录.

这并没有抓住Swift崩溃的东西.

是否有可能在Swift的全球范围内做这样的事情?例如,如果在Swift代码中发生崩溃,请执行一些日志记录,例如强制解包nil可选.

具体来说,我正在做一个实用程序来记录应用程序中的网络流量,如果发生崩溃,我想将内存中的数据刷新到磁盘.

crash exception ios swift

15
推荐指数
3
解决办法
8693
查看次数

Swift协议扩展方法用超类和子类调度

我发现了一个有趣的行为,似乎是一个bug ...

基于以下文章描述的行为:

https://medium.com/ios-os-x-development/swift-protocol-extension-method-dispatch-6a6bf270ba94

http://nomothetis.svbtle.com/the-ghost-of-swift-bugs-future

当我添加时SomeSuperclass,输出不是我所期望的,而不是直接采用协议.

protocol TheProtocol {
    func method1()
}

extension TheProtocol {
    func method1() {
        print("Called method1 from protocol extension")
    }
    func method2NotInProtocol() {
        print("Called method2NotInProtocol from protocol extension")
    }
}

// This is the difference - adding a superclass
class SomeSuperclass: TheProtocol {
}

// It works as expected when it simply adopts TheProtocol, but not when it inherits from a class that adopts the protocol
class MyClass: SomeSuperclass {
    func method1() {
        print("Called …
Run Code Online (Sandbox Code Playgroud)

protocols ios swift protocol-extension

8
推荐指数
1
解决办法
1984
查看次数