UISwipeGesture'无法识别的选择器发送到实例'

时间:2016-06-24 01:53:03

标签: ios swift swift3

如果有人可以帮我解决这个问题,那就太好了!我花了几个小时试图修复,没有运气

错误...

  

2016-06-23 20:30:43.341057 Scaling Rings [408:38903] [DYMTLInitPlatform]平台初始化成功   2016-06-23 20:30:43.750822 Scaling Rings [408:38776]启用金属GPU帧捕获   2016-06-23 20:30:43.751531 Scaling Rings [408:38776]启用了金属API验证   2016-06-23 20:30:48.293661 Scaling Rings [408:38776] - [Scaling_Rings.MenuScene slide:]:无法识别的选择器发送到实例0x145e1c410   2016-06-23 20:30:48.299061 Scaling Rings [408:38776] *由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:' - [Scaling_Rings.MenuScene slide:] :无法识别的选择器发送到实例0x145e1c410'   * 第一次抛出调用堆栈:   (0x190ad9980 0x1900d44bc 0x190ae0778 0x190add6e0 0x1909de61c 0x196e13754 0x196e16e5c 0x1969f6b3c 0x196894900 0x196e0747c 0x196e07100 0x196e06338 0x196892a24 0x1968638c8 0x19701efd4 0x19701941c 0x190a8a3f0 0x190a89cc8 0x190a87938 0x1909ba2e4 0x19239315c 0x1968ce6fc 0x1968c9438 0x1000a1d44 0x19055c600)   libc ++ abi.dylib:以NSException类型的未捕获异常终止   (LLDB)

代码...

import Foundation
import SpriteKit

var startRing = SKShapeNode()

class MenuScene: SKScene {

    func slide(sender: AnyObject){
        debugPrint("WORKS")
    }

    override func didMove(to view: SKView) {

        let upSwipe = UISwipeGestureRecognizer(target: self, action: Selector("slide:"))
        upSwipe.direction = .up
        view.addGestureRecognizer(upSwipe)

    }

}

2 个答案:

答案 0 :(得分:6)

您需要将选择器声明更改为topViewController.title并在方法参数#selector(slide)之前添加下划线:

func slide(_ sender: UISwipeGestureRecognizer)

答案 1 :(得分:0)

Swift 4.2

在下面的情况下,我们使用参数来分配目标。这只能用字符串完成

select si.pid,
si.item_name,
ifnull(sum(`si`.`item_qty`), 0) as total_items_count,
ifnull(format(sum(`si`.`item_total`),2), '0.00') as total_items_amount
from wo_tbl_sales_items si
where si.pdate = '2018-07-21' 
group by si.pid,si.item_name
order by total_items_count DESC