我有一个VC,点击按钮想要打开第一个索引上的标签栏VC。我通过现在的风格打开了这个。我家的vc在标签栏的第一个索引上。我怎么能打开它?我的UI看起来像那样,
我试过的代码就是这个,
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabbarVC = storyboard.instantiateViewController(withIdentifier: "MainVC") as! MainVC
if let vcs = tabbarVC.viewControllers,
let nc = vcs.first as? UINavigationController,
self.present(tabbarVC, animated: false, completion: nil)
答案 0 :(得分:4)
你可以给一个id并直接打开
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabbarVC = storyboard.instantiateViewController(withIdentifier: "MainVC") as! MainVC
self.present(tabbarVC, animated: false, completion: nil)
//
const char* tmp = raw_data_buffer->str().c_str();
// ^^^^^ returns a temporary that is destroyed
// at the end of this statement
// ^^^ now a dangling pointer