Problem with simple UIRotationGestureRecognizer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with simple UIRotationGestureRecognizer

Zipette
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



--
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with simple UIRotationGestureRecognizer

Sam Stigler
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


On Jan 25, 2015, at 4:58 PM, Zipette <[hidden email]> wrote:

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



--
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/A22FDC1C-64FA-4C94-8DC3-B9431B30F4CE%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with simple UIRotationGestureRecognizer

Zipette
Hello SAm,
Thks for your answer. How do I invoke the designated initializer for this class ?
Thks.


Le lundi 26 janvier 2015 00:23:33 UTC+1, Sam Stigler a écrit :
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


On Jan 25, 2015, at 4:58 PM, Zipette <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="L1YnIdscfGYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">conta...@votrecalendrier.com> wrote:

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



--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="L1YnIdscfGYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">swift-languag...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="L1YnIdscfGYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">swift-l...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" onclick="this.href='https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;">https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/7745147a-7551-4935-bbcc-aa1ea7bc5860%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with simple UIRotationGestureRecognizer

Sam Stigler
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

On Jan 26, 2015, at 4:16 AM, Zipette <[hidden email]> wrote:

Hello SAm,
Thks for your answer. How do I invoke the designated initializer for this class ?
Thks.


Le lundi 26 janvier 2015 00:23:33 UTC+1, Sam Stigler a écrit :
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


On Jan 25, 2015, at 4:58 PM, Zipette <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="L1YnIdscfGYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">conta...@votrecalendrier.com> wrote:

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



--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="L1YnIdscfGYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">swift-languag...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="L1YnIdscfGYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">swift-l...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" onclick="this.href='https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;">https://groups.google.com/d/msgid/swift-language/06c9ecea-ec81-447d-b4a1-e1ad67bccdbe%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/7745147a-7551-4935-bbcc-aa1ea7bc5860%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/3B9DBD55-7F8E-4791-AE84-05BFC737D3CB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.