ios - 警告 : Attempt to present ZMNavigationController on **. ViewController 其 View 不在窗口层次结构中

标签 ios swift sdk

伙计们,我在 NavigationController 方面遇到了一个奇怪的问题。现有的答案根本没有帮助!!!!

这是应用程序的基本场景:

  1. There are two views - Main and Second view
  2. In main view there is a button when i happen to tap goes into second view using segue.
  3. In second view after i enter a certain field in text view and click on a button called "join" it triggers "joinMeeting()" function and meeting should be joined.

但是,当我这样做时,调试器会向我显示:

"Warning: Attempt to present on <***.ViewController: *****> whose view is not in the window hierarchy!"

所以我已经阅读了大部分内容,并且考虑到它是由于 viewDidAppear 方法而发生的,但在 viewDidAppear 之前我还需要完成 nth 操作。单击按钮后一切都会发生。

joinMeeting() is successfully called and print method returns 0 which means no issue(https://developer.zoom.us/docs/ios/error-codes/) and successful SDK connection however after this "Warning" error is shown in debugger and nothing happens in the app.

如果有帮助的话,下面是触发 joinBtn 的代码:

/**
Triggers when Join Button is clicked from second view.
*/
    @IBAction func joinMeeting(_ sender: Any) {
            if( activityID.text == "" ) {
                let alert = UIAlertController(title: "Field is Blank", message: "Activity ID cannot be blank.", preferredStyle: UIAlertControllerStyle.alert)
                alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil))
                self.present(alert, animated: true, completion: nil)

                return;
            }


            let ms: MobileRTCMeetingService? = MobileRTC.shared().getMeetingService()
            if ms != nil {
                ms?.delegate = self;

                // //For Join a meeting
                let paramDict: [AnyHashable: Any] = [
                    kMeetingParam_Username: kSDKUserName,
                    kMeetingParam_MeetingNumber: activityID.text!,
                ]

                let ret: MobileRTCMeetError? = ms?.joinMeeting(with: paramDict)
                print("onJoinaMeeting ret:\(String(describing: ret))")
            }
        }

如果有人知道或知道我在这里缺少什么,请提供帮助。

最佳答案

以下是解决问题的方法:

Storyboard配置: ViewController --Segue: Show--> JoinViewController

@IBAction func onClickJoin(_ sender: AnyObject) {
        //Main storyBoard
        let initialVC = UIStoryboard(name: "Main", bundle:nil).instantiateInitialViewController() as! UIViewController

        let appDelegate = (UIApplication.shared.delegate as! AppDelegate)

        appDelegate.window?.rootViewController = initialVC

        //Rest of the code
    }

关于ios - 警告 : Attempt to present ZMNavigationController on **. ViewController 其 View 不在窗口层次结构中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49231314/

相关文章:

ios - 如何从 iCarousel 中的按钮创建到另一个 View 的 segue

ios - Swift iOS 9 二维码扫描仪

iOS Segue - 从左到右 -

ios - WeMo Local SDK Demo iOS App DidFoundDevice Never Called

ios - 将数据从 tableviewcontroller 发送到 detailviewcontroller

ios - 如何使用 Swift 从 Assets 中加载特定图像

ios - 如何在 Swift 中同步检索 PFUser objectForKey

android - 如何列出来自 EvernoteNoteStoreClient.findNotes() 的笔记?当 notefilter 为空时,我可以列出所有笔记本

c++ - 如何在 C++ 项目的 Cmake 文件中添加 Mac OS 框架

ios - 将 SubView 添加到 UITableViewCell 不会显示