ios 继续“取消”
根据 XML 返回,我不希望当前的 segue
在 UIButton 触摸上执行。
我知道我可以选择要执行的segue
,但是如何让segue
不执行呢?或者至少不执行任何可用的segues
?
Depending on an XML return, I don't want the current segue
to perform on UIButton touch.
I know I can pick which segue
I want to perform, but how to I make a segue
not perform? Or at least not perform any of the available segues
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的部署目标是 iOS 6.0 或更高版本,您可以覆盖
-[UIViewController shouldPerformSegueWithIdentifier:sender:]
方法,如果您想执行转场,则返回YES
;如果不想执行,则返回NO
。如果您的部署目标早于 iOS 6.0,您将不会收到
shouldPerformSegueWithIdentifier:sender:
消息。因此,在故事板中,不要从按钮绘制转场。相反,从按钮的视图控制器中绘制 Segue 并为 Segue 提供一个标识符。将按钮连接到其视图控制器中的IBAction
。在操作中,检查是否要执行segue。如果您想执行它,请发送给自己performSegueWithIdentifier:sender:
,将您分配给的标识符传递给在故事板中继续。If your deployment target is iOS 6.0 or later, you can override the
-[UIViewController shouldPerformSegueWithIdentifier:sender:]
method to returnYES
if you want to perform the segue andNO
if you don't.If your deployment target is earlier than iOS 6.0, you won't receive the
shouldPerformSegueWithIdentifier:sender:
message. So in your storyboard, don't draw the segue from the button. Instead, draw the segue from the button's view controller and give the segue an identifier. Connect the button to anIBAction
in its view controller. In the action, check whether you want to perform the segue. If you want to perform it, send yourselfperformSegueWithIdentifier:sender:
, passing the identifier you assigned to the segue in the storyboard.Apple 开发者文档 具有取消在 StoryBoard 中管理的 segue 的正确方法:
例如:
Apple Developer Documentation has the correct method to cancel a segue that is managed within the StoryBoard:
For example:
查看此线程: https://stackoverflow.com/a/42161944/4791032
您可以在
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath)
Check out this thread: https://stackoverflow.com/a/42161944/4791032
You can just check it in
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath)