我需要有关错误修复的帮助。我使用segue在ViewController之间进行转换。
我有一个UITabBarController
和一个UIViewController
。当我单击vc中的按钮时,我将移至第二个vc。我的第二个vc没有TabBar。 (使用segue)。在第二个vc中,我有按钮和UIAlertController
。当我单击按钮或警报时,我必须使用TabBar转换到第一个vc,但不会显示我的TabBar。如何解决呢?我don't
需要使用NavigationController
。
let alert = UIAlertController(title: "Поздравляю", message: "Тренировка окончена", preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Click", style: UIAlertAction.Style.default, handler: { action in self.performSegue(withIdentifier: "backSegue", sender: self) }))
self.present(alert, animated: true, completion: nil)
答案 0 :(得分:0)
如果要显示第二个ViewController,请将其模态添加到UIAlertController操作中:
self.dismiss(animated: true, completion: nil)
答案 1 :(得分:0)
将以下代码从FirstViewController
移至NextController
的位置添加到segue
。
- (IBAction)unwindToFirst:(UIStoryboardSegue *)unwindSegue {
UIViewController* sourceViewController = unwindSegue.sourceViewController;
if ([sourceViewController isKindOfClass:[SecondViewController class]]) {
NSLog(@"Coming from SECOND!");
} else {
NSLog(@"Handle Error");
}
}
然后转到情节提要,右键单击并按住,然后从Button
上的NextController
拖动到退出响应程序。
出现方法名称,然后连接到该名称。