将viewController从项目导入到Swift / Objective-C中的库

问题描述

我为我的应用程序提供了一些可重用性模块/选项卡。我通过Cocoapods添加了库。我有“通用”模块,其中包含所有选项卡的通用元素,但有时需要大量依赖项导入。

Xcode

是否可以ExampleViewController从“ MyApp”导入另一个库,例如Wall?我通常从“通用”中导入。

为什么#import <MyApp/ExampleViewController-Swift.h>不起作用?

下面是我对该ViewController的调用函数。如何使用捆绑包?

enter image description here

解决方法

好的,我看不到答案。我自己找到的。

如果有人有类似情况。答案是NSNotificationCenter

将函数添加到要打开的SettingsViewController处:

@IBAction func userPhotoClicked(_ sender: Any) {
NotificationCenter.default.post(name: Notification.Name("profileSide"),object: nil) }

并在此ViewController(用Objective-c编写)上,在其中添加观察者的动作:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(profileSide:) name:@"profileSide" object:nil];

并删除观察者:

[[NSNotificationCenter defaultCenter] removeObserver:self name:@"profileSide" object:nil];

并在具有AddObserver和RemoveObserver的同一视图控制器上编写函数“ profileSide”。

- (void)profileSide:(NSNotification *)notification {
    SettingsViewController *vc = [[SettingsViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

祝一切顺利。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...