伙计们,我在 NavigationController
方面遇到了一个奇怪的问题。现有的答案根本没有帮助!!!!
这是应用程序的基本场景:
- There are two views - Main and Second view
- In main view there is a button when i happen to tap goes into second view using segue.
- 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/