您当前的位置: 首页 >  swift

Swift:

发布时间:2017-10-03 18:51:51 ,浏览量:0

初学iOS开发的童鞋可能会遇到各式奇怪的问题,这篇博文本猫就为大家介绍其中一个”怪异”问题.

该问题很好重现: 1.使用xcode新建一个最简单的单vc工程,然后在Storyboard中新建一个destVC.然后从默认创建的VC(姑且称之为initVC)拉一条segue到destVC,并设置该segue ID为”ToDestVC”

2.打开initVC类,只添加2个方法:

override func touchesBegan(_ touches: Set, with event: UIEvent?) { super.touchesBegan(touches, with: event)
        NSLog("在destVC中触摸屏幕却会执行initVC中的这句代码")
    } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated)

    performSegue(withIdentifier: "ToDestVC", sender: nil)
}

3.好了,只需要修改这么多.现在编译运行app,由于上面代码的原因,首先initVC被显示,但很快切换到destVC中去.此时在destVC的视图中轻触屏幕,你会发现却是initVC中的

关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    107766博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0514s