0
Swift for Copy Optionでジェスチャーを長押ししようとしています。Swift、UILongPressGestureRecognizer UIlabelで動作しません
しかし、動作していません。 UiViewまたはUILabelでジェスチャーを識別していません。以下は
私はクラス
0の宣言にすぎUIGestureRecognizerDelegateを追加している私のコードビューDidLoadで
let copyLongPress = UILongPressGestureRecognizer(target: self, action: #selector(ContactDetailController.handleLongPress(_:)))
copyLongPress.numberOfTouchesRequired = 0
copyLongPress.delegate = self
copyLongPress.minimumPressDuration=0.5
self.lblDynaMobile.addGestureRecognizer(copyLongPress)
self.lblDynaMobile.userInteractionEnabled = true
self.lblDynaDDI.addGestureRecognizer(copyLongPress)
self.lblDynaDDI.userInteractionEnabled = true
self.GeneralView.addGestureRecognizer(copyLongPress)
self.EmailView.addGestureRecognizer(copyLongPress)
self.AddressView.addGestureRecognizer(copyLongPress)
新優先mothod
func handleLongPress(longPressView :UILongPressGestureRecognizer) {
let lblFont:UILabel = (longPressView.view as? UILabel)!
UIPasteboard.generalPasteboard().string = lblFont.text
}
です
チェックこの回答http://stackoverflow.com/questions/10613118/uilabel-uilongpressgesturerecognizer-not-working?rq=1 – sanman
@sanmanborate、私はすでにそれを行っています..しかし、動作していません.. self.lblDynaMobile.userInteractionEnabled = true –
@dhavalshah、この答えを確認してくださいhttp://stackoverflow.com/questions/13929703/why-does-uitableviews-swipe-delete-sometimes-work -fine-sometimes-not/20157326#20157326 – bademi