标签: uitapgesturerecognizer

UITapGestureRecognizer彼此冲突

所以我有两个UITapGestureRecognizer,一个用于单击,另一个用于双击.但是,当我进行双击时,也会触发单击动作手势识别器.有没有办法禁用它,以便双击只调用双击操作?

iphone objective-c ipad ios uitapgesturerecognizer

0
推荐指数
1
解决办法
145
查看次数

如何在 Swift 中知道发件人的标识符

我有两个UILabels,两个UITapGestureRecognizers在一个UITableViewCell.

cell.Username.tag = indexPath.row
cell.SharedUser.tag = indexPath.row
let tapGestureRecognizer2 = UITapGestureRecognizer(target:self, action:"GoToProfil:")
let tapGestureRecognizer3 = UITapGestureRecognizer(target:self, action:"GoToProfil:")
cell.Username.userInteractionEnabled = true
cell.Username.addGestureRecognizer(tapGestureRecognizer2)
cell.SharedUser.userInteractionEnabled = true
cell.SharedUser.addGestureRecognizer(tapGestureRecognizer3)

func GoToProfil (sender: AnyObject!) {
    self.performSegueWithIdentifier("GoToProfilSegue", sender: sender)
}
Run Code Online (Sandbox Code Playgroud)

我正在使用 aSegue来推送另一个UIViewController,并且我正在覆盖该PrepareSegue函数以发送与Sender标签相对应的所需信息。

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {

    let ProfilView = segue.destinationViewController as! Profil
    ProfilView.hidesBottomBarWhenPushed = true
    ProfilView.title = posts[sender.view!.tag].User?.objectForKey("Name") as? String
    ProfilView.User = posts[sender.view!.tag].User
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我想知道UILabel按下了哪个,知道我已经在使用tag.

ios uitapgesturerecognizer segue swift

0
推荐指数
1
解决办法
2370
查看次数

(Swift) How to get rid of "Left side of mutating operator isn't mutable"

complete error:

Left side of mutating operator isn't mutable: 'abc' is a 'let' constant

Happens because I am trying to change value of a variable sent by parameter to function.
Can I get rid of this, or find some other solution?
Code(My code is much complex, but in effect doing the same as this):

func generateABC() {
var abc = "this"
abc += "is"

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(abc)) )
tapGesture.delegate = self
webView.addGestureRecognizer(tapGesture)

abc += "function"
} …
Run Code Online (Sandbox Code Playgroud)

ios uitapgesturerecognizer swift

-1
推荐指数
1
解决办法
831
查看次数

我们可以为UILabel添加Tap手势吗?

我在UIView中添加了Label并创建了它的插座,然后在UITapGestureRecognizer的帮助下我添加了功能,但是当我点击或点击标签时.标签文本不会更改.我搜索了类似的问题,我得到的答案也是我写的,但标签文字仍未改变.用Swift 3.0编写的代码.这是我写的代码 -

 import UIKit

class testingViewController: UIViewController {

    @IBOutlet weak var testLabel: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
      let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(showDatePicker))
      tap.numberOfTouchesRequired = 1
      tap.numberOfTapsRequired = 1
      testLabel.addGestureRecognizer(tap)
      testLabel.isUserInteractionEnabled = true// after adding this it worked
        // Do any additional setup after loading the view.
    }

  func showDatePicker(){
    print("testing")
  }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, …
Run Code Online (Sandbox Code Playgroud)

uilabel ios uitapgesturerecognizer swift3

-2
推荐指数
1
解决办法
3267
查看次数