[英]Import viewController from project to library in swift/objective-c
好的,我看到没有答案。 我自己找到了。
如果有人有类似情况。 答案是NSNotificationCenter
。
添加到您想要打开SettingsViewController
的 function :
@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];
并在同一个视图 controller 上写 function “profileSide”,其中您有 AddObserver 和 RemoveObserver。
- (void)profileSide:(NSNotification *)notification {
SettingsViewController *vc = [[SettingsViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
一切顺利。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.