我想将发件人 func application(application: UIApplication,
handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?,
reply: (([NSObject : AnyObject]!) -> Void)!) {
if let userInfo = userInfo, request = userInfo["SiteName"] as? String {
let siteName = userInfo["SiteName"] as? String
reply(["Message":"Received launch request from \(siteName)"])
UIApplication.sharedApplication().openURL(NSURL(string: "DSExtension://more")!)
}
}
传递给函数redBox
。我不知道如何传递不是leftSwipeFunc
的参数。如果你知道答案,请帮助我。
UISwipeGestureREcognizer
答案 0 :(得分:2)
手势识别器有一个名为view
的属性,它是附加到的UIView
。因此,您可以在leftSwipeFunc
内使用它来获取视图:
func leftSwipeFunc(gesture: UISwipeGestureRecognizer) {
let swipedView = gesture.view
// Assuming redBox is a property of your view controller
if swipedView == redBox {
println("the redBox was swiped")
} else {
println("some other view was swiped")
}
}
答案 1 :(得分:0)
您可以使用locationInView
在视图中找到滑动的位置。
在leftSwipeFunc
中,找到触摸屏的CGPoint
,然后检查它是否在所需的视图中。
let location = gesture.locationInView(self.view)
if CGRectContainsPoint(redBox, location) {
// redBox was swiped, do something
}