
我会告诉你一个屏幕截图,但我没有足够的声誉(我曾经遇到的其他问题我可以找到其他人的帖子).
它甚至会显示带有填充点的圆圈,单击时会显示正确的按钮.在连接检查器中,它在发送的事件下显示“touch Up InsIDe”和“UserPage btnProgressClick”之间的连接(Userpage是我的类,它扩展了UIVIEwController并被这个微粒VIEw Controller引用,btnProgressClick是我想要的IBAction函数的名称跑).
我找到了this post,我尝试了一个干净的构建但是没有用.我也移动了我的按钮,它在模拟器中正确更新.
btnProgressClick中的代码永远不会执行.我在第一行放了一个断点,它没有断开.
这是将按钮链接到函数的“Main.storyboard”XML代码.
<!--User Page--> <scene sceneID="aNb-aX-hZF"> <objects> <vIEwController storyboardIDentifIEr="UserPage" ID="w2h-zR-Kdu" customClass="UserPage" customModule="GenomeTrackerDemo" customModuleProvIDer="target" sceneMemberID="vIEwController"> <layoutGuIDes> <vIEwControllerLayoutGuIDe type="top" ID="9dS-Hw-ZYg"/> <vIEwControllerLayoutGuIDe type="bottom" ID="7PS-pA-lFe"/> </layoutGuIDes> <vIEw key="vIEw" contentMode="scaletoFill" ID="w6A-eT-aKv"> <rect key="frame" x="0.0" y="0.0" wIDth="600" height="600"/> <autoresizingMask key="autoresizingMask" wIDthSizable="YES" heightSizable="YES"/> <subvIEws> <button opaque="NO" contentMode="scaletoFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="mIDdleTruncation" translatesautoresizingMaskIntoConstraints="NO" ID="JGD-xx-tMQ"> <rect key="frame" x="20" y="48" wIDth="46" height="30"/> <state key="normal" title="button"/> <connections> <action selector="btnProgressClick:" destination="w2h-zR-Kdu" eventType="touchUpInsIDe" ID="F1N-QY-fhb"/> </connections> </button> </subvIEws> <color key="backgroundcolor" white="1" Alpha="1" colorSpace="calibrateDWhite"/> </vIEw> </vIEwController> <placeholder placeholderIDentifIEr="IBFirstResponder" ID="Fsq-L4-Are" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="1043" y="426"/> </scene>
这是UserPage类:
import Foundationimport UIKitclass UserPage: UIVIEwController { var thisUser: User = User() overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() } @IBAction func btnProgressClick(sender: UIbutton) { let storyboard = UIStoryboard(name: "Main",bundle:nil) let vc: progresspage = storyboard.instantiateVIEwControllerWithIDentifIEr("progresspage") as! progresspage UIVIEw.TransitionFromVIEw(self.vIEw,toVIEw: vc.vIEw,duration: 0.8,options: UIVIEwAnimationoptions.TransitionFlipFromright,completion: nil) }} 正如我之前所说,这是我的第一个问题,所以我愿意接受有关措辞如何以及我提供的信息的反馈.
我想添加一些有关如何调用此页面的信息.在对Web服务进行异步调用之后调用它.数据成功恢复后,我转换到具有此功能的页面:
func afterSuccessfulLogin(thisUser: User){ dispatch_async(dispatch_get_main_queue()){ let storyboard = UIStoryboard(name: "Main",bundle:nil) let vc: UserPage = storyboard.instantiateVIEwControllerWithIDentifIEr("UserPage") as! UserPage vc.thisUser = thisUser UIVIEw.setAnimationCurve(.EaseIn) UIVIEw.TransitionFromVIEw(self.vIEw,duration: 1.2,completion: nil) }} 不确定这是否有所作为,但我想我会把它扔在那里.
对此问题的任何帮助都非常有用.
谢谢!!
解决方法 [删除之前的答案,由于有问题的其他信息]iOS包含视图层次结构和视图控制器层次结构.这两者都需要保持一致.在问题中发布的代码中,仅处理视图层次结构.请尝试以下更改:
>在调用TransitionFromVIEw之前调用addChildVIEwController:on self:toVIEw:duration:options:completion:传递vc.
>在TransitionFromVIEw的完成块中:toVIEw:duration:options:completion:方法,调用dIDMovetoParentVIEwController:on vc,传递self.
let storyboard = UIStoryboard(name: "Main",bundle:nil)let vc: UserPage = storyboard.instantiateVIEwControllerWithIDentifIEr("UserPage") as! UserPagevc.thisUser = thisUserUIVIEw.setAnimationCurve(.EaseIn)self.addChildVIEwController(vc)UIVIEw.TransitionFromVIEw(self.vIEw,completion: { (finished) -> VoID in vc.dIDMovetoParentVIEwController(self) }) 调用TransitionFromVIEw:toVIEw:duration:options:completion:并将self.vIEw作为fromVIEw参数传递也有点奇怪.通常会删除fromVIEw参数并将其替换为toVIEw参数,该参数会使视图控制器层次结构中的原始视图控制器在视图层次结构中没有实际视图.引入要替换的嵌套UIVIEw而不是self.vIEw可能是明智之举.
总结以上是内存溢出为你收集整理的ios – IBAction func正确连接但未执行全部内容,希望文章能够帮你解决ios – IBAction func正确连接但未执行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)