How do you make an UIImageView on the storyboard clickable (swift)

前端 未结 7 670
后悔当初
后悔当初 2020-12-13 02:39

I am new to swift (and Xcode development in general) and I was wondering how to make an ImageView on the storyboard clickable. What I\'m trying to do is make it so when its

7条回答
  •  情深已故
    2020-12-13 03:04

    On the storyboard set image view user interaction enabled and then get with this method

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
    {
        UITouch *touch = [touches anyObject];
    
        if ([touch view] == yourImageView)
        {
                //add your code for image touch here 
        }
    }
    

提交回复
热议问题