I’m creating an app for the iphone in xcode where the background image is much larger than the screen. I’ve added in a pan gesture recognizer to the imageview of the background, which allows it to be moved freely so the user can see beyond the character they control.
This is working perfectly, but when I add in additional imageviews(for the character and other objects throughout the area) they will remain stationary. Is there a way to connect multiple imageviews to a single pan gesture recognizer so that when one is moved, they all move together?
I tried connecting the other imageviews to the referencing outlet collections of the pan gesture recognizer, but when the program is run it only pans the last imageview connected, while the others remain stationary.
I’m new to xcode, and I’m sure this is something relatively simple that I’m overlooking, but I haven’t been able to find an answer on the internet so any help would be appreciated. 🙂
Thanks!
The best way is to make the character (and other views) a subview of the backgroundImage.
Note that in the NIB (.xib) file you cannot add a Subview to UIImageView but you can do it programatically.
If you prefer working in the NIB file you can make a “container” UIView that holds the background image and other characters inside that view.
Then for the gesture recognisers you’ll transform that view.