我有2个viewcontrollers:mainVC& listVC。 我点击了mainVC上的自定义按钮来显示listVC,然后点击listVC上的按钮返回mainVC。到现在为止没有任何失败。但当我点击自定义按钮再次进入listVC时,程序失败。
错误: NSInvalidArgumentException',原因:'应用程序试图在自身上呈现模态视图控制器。提出控制器是 Voice_of_Animals.ListVC:0x7feeee513210>
class ViewController: UIViewController
{
var cb = CirButton(Circolor: UIColor.cyan, Rsize: 100, PositionX: 100, PositionY: 100)
override func viewDidLoad() {
super.viewDidLoad()
mainVC = self
self.view.addSubview(cb)
listVC.transitioningDelegate = listVC as UIViewControllerTransitioningDelegate
}
func showNextPage() {
self.present(listVC, animated: true, completion: nil)
}
@IBAction func show(_ sender: UIButton) {
self.present(listVC, animated: true, completion: nil)
}
@IBAction func Touch(_ sender: CButton) {
sender.RunAnimation()
}
override func didReceiveMemoryWarning() {
}
}
class ListVC: ViewController{
var transition = FadeAnimator()
var btn1 = CirButton(Circolor: UIColor.cyan, Rsize: 100, PositionX: 100, PositionY: 100)
@IBOutlet weak var myList: ListView!
@IBAction func Push(_ sender: UIButton) {
}
@IBAction func edgeSlide(_ sender: UIScreenEdgePanGestureRecognizer) {
mainVC.dismiss(animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(btn1)
}
}