Problem with simple UIRotationGestureRecognizer

已查看 38 次
跳至第一个未读帖子

Zipette

未读,
2015年1月25日 17:58:082015/1/25
收件人 swift-l...@googlegroups.com
Hello,
I want to use the UIRotationGestureRecognizer to rotate an UIView with two fingers on the IOS simulator, here is my Swift code in ViexController:


import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var myView: UIImageView!

    override func viewDidLoad() {

        super.viewDidLoad()

        let gestureRec = UIRotationGestureRecognizer()

        gestureRec.addTarget(myView, action: "rotate:")

        myView.addGestureRecognizer(gestureRec)

        myView.userInteractionEnabled = true

        myView.multipleTouchEnabled = true

    }

    func rotate(sender:UIRotationGestureRecognizer)

    {

        myView.transform=CGAffineTransformRotate(myView.transform, sender.rotation)

        sender.rotation=0

        println("ok !")

    }


Unfortunatly this code doesn't work for a raison I can't find, could someone help me ?

Thks in advance.
Zipette



Sam Stigler

未读,
2015年1月25日 18:23:332015/1/25
收件人 Zipette、swift-l...@googlegroups.com
It looks like you're not using the designated initializer for that class. Have you tried with that to see if it makes a difference?

Sam

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swift-languag...@googlegroups.com.
To post to this group, send email to swift-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zipette

未读,
2015年1月26日 05:16:262015/1/26
收件人 swift-l...@googlegroups.com、conta...@votrecalendrier.com
Hello SAm,
Thks for your answer. How do I invoke the designated initializer for this class ?
Thks.

Sam Stigler

未读,
2015年1月26日 09:43:282015/1/26
收件人 Zipette、swift-l...@googlegroups.com
Hi Zipette,

Check in the documentation for the superclass. In this case, the superclass is UIGestureRecognizer, and its designated initializer is init(target targetAnyObject,
     action actionSelector) . It should show up in Xcode's autocomplete menu if you type in UIRotationGestureRecognizer( .

Sam
回复全部
回复作者
转发
0 个新帖子