可以在运行时更改AppDelegate

可以在运行时更改AppDelegate

本文介绍了可以在运行时更改AppDelegate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在运行时将UIApplication.delegate属性更改为另一个实现UIApplicationDelegate协议的类,以便从那时起在新类上调用UIApplicationDelegate函数?

Is it possible to change the UIApplication.delegate property at runtime to another class that implements the UIApplicationDelegate protocol so that from then on UIApplicationDelegate functions are called on the new class?

推荐答案

您可以非常简单地使用 [UIApplication sharedApplication] .delegate = instanceOfDifferentClass 进行更改。

You can very simply change it with [UIApplication sharedApplication].delegate = instanceOfDifferentClass.

这篇关于可以在运行时更改AppDelegate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 16:23