Touch and Hold Swift
Recently, at VID, I created a functional iPad application for a client’s property platform. One function was panning a 360 image on a Windows application.
Prior to working on these Swift methods our team created a Windows launcher and API to connect with and show these images on the screen. One of the images that needed panoramic capability were the floor views. In the Main.storyboard file I created one View Controller for these API calls. As you can see each view has a left and right arrow which will repeat call the API to move left or right.
To be brief, here is one variable of the first right button on the Main.storyboard as well as the leftTimer and rightTimer variables that will be used in the future “touch and hold” methods.
1 2 3 4
rightButtonDown methods repeatedly call the
moveRight methods every 0.1 second while the user continues to press the view button. Once the user lifts their finger up which is considered a
Touch Up type of Swift method the timer becomes invalid and panoramic capability ceases.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
moveRight methods are simple HTTP GET requests using a Swift NSMutableURLRequest(). In the Windows API this URL call will move the image a small percentage to the left or right, together with the panoramic capability methods this ensures a panoramic view without breaks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
All that’s left is to connect the buttons with the methods we just created. Again, to be brief I only am showing the first right button but were we to look at all the buttons, the right buttons would look exactly like this while the left buttons would connect to the
Keep on being badass programmers!