Interactive ImageView in iOS - ios

I have been researching for a while, and I have found a lot of questions and answers on how to use a gesture recognizer on a UIImageView in iOS to make the image interactive. However, I am hoping to make an interactive image that reacts differently depending on the part of the image that is tapped (think of an interactive map or an interactive image of the human body).
I am still in the planning phase, but I cannot think of a way to do this. My first idea was to use UIButtons over the image, but I cannot think of a way to make the constraints allow the buttons to remain stationary over the image for different devices. I am looking for ideas, either on another way of doing this, or a way to make the constraints work.

Related

iOS - Animated background image (GIF)

I am currently developing a weather app.
For now I have just implemented static background image on the Home page that vary depending on the current weather.
I would like to improve this feature in order to provide a better user experience.
I think that with the rapid growth of technology, hardware, wifi but even frameworks and developing tools we are able to make greater and greater Apps each days.
That's why I am really interested about knowing different ways to improve my App.
Moreover, I think that the proper/coolest way to differentiate my App from the weather-app market is to have unique features or at least "more enjoyable" than others.
I really don't know where to start, I have read 3 different posts on StackOverflow about animated background without success.
I would like to know which solution is better in order to implement animated background image.
Should I play a short video infinitely, like a GIF ?
In term of battery consumption, should I worry about that ? Even knowing that the average app-navigation time for a weather app is approximatively 47s.
PS: I am developing with Objective C.
If you have any suggestions, any informations, I'll take it.
Thank you in advance.
There is a way to create a continuously animated image. What you do is create a UIImage with a special initializer (see final line). You give this initializer the base name of an image, like “storm”. The understanding is that you will have several files named storm1.png, storm2.png, etc., the succession of which will constitute an animation. All you do is call the initializer and specify how long you’d like each animation frame to last, and all the rest is automatic. The image view that gets created will continue cycling through however many animation frames you have. As long as that image view is visible, Apple’s code will guarantee the image will be continuously animating. As soon as it gets to the end of the list (say, storm8 if you have 8 frames in your animation), it automatically starts over. At least in Swift, you don’t even have to tell it the file extension of the images.
If you want the image to cover the entire background of your view controller, just set up the imageView in Interface Builder to be pinned to the left, right, top, and bottom of the main view of your view controller.
Here’s the syntax for creating the continuously animated image in your code:
UIImage *image = [UIImage animatedImageNamed:#"storm.jpg" duration:0.5f];
Or in Swift:
let imageView.image = UIImage.animatedImageNamed("storm", duration: 0.5)

Positioning and Resizing handles similar to Apple Pages

In Apple's Pages app it allows you to add an image or text box or shape layer to the page then resize it by tapping on it and the handles appear. A similar thing also happens in the Pixelmator app and a few others. Is this something made by Apple that I can use in my app or would I have to build it in myself?
As far as I know there is no system support for resize handles and you will need to build it yourself. That's what I've done when I needed them. I added views on top of the thing that I wanted to resize, with pan gesture recognizers attached.
I have an app called CIFilterTest on Github (written in Objective-C, unfortunately) that uses resize handles to let the user move around points and rects when they are needed for the various Core Image filters. Even though it's written in Objective-C it should give you the idea.
Note that most Core Image filters run VERY slowly on the simulator, making the app seem extremely laggy. That's an artifact of running Core Image filters on the simulator. It runs much faster on an actual iOS device.

Is it posible to insert a UITextView (or other UIKit view) into an augmented reality SCNScene?

Weird crazy question I know. My current setup is a SCNScene with a camera controlled by the device's gyroscope. I'm able to add and light normal nodes, however I would like to add 2D UIView objects into the scene like UITextViews or maybe some buttons. The views would need to be inside the scene and thus become no longer visible if the camera moves away from them.
Firstly, is this even possible? Or would this be way more difficult to implement than rebuilding an editable textview as a node? Could this be achieved by categories or...?
I just talked to the scenekit people here at WWDC. He said that as of now it is completly impossible to do it in a nice, functional way. The only options he offered as a possible solution is to create the UIView element somewhere off screen or behind the scene and continuously take screenshots of the object and apply those images as a texture to a SCNNode. He also pointed out the performance will be very poor with this because taking screenshots is heavy and you can't get going very quick with it. So I guess this is a no-go until UIView adds support because, according to the engineer, it's impossible to implement this because of a UIView limitation and not a SceneKit one.

How can i stack up tiles in iOS programming?

I'm trying to learn iOS programming and I decided to make a game like Connect 4, or some may know it as Four in a row.
I've done the grid and dropping the tiles. However, I haven't been able to stack the tiles on top of each other. I havent tried that much because I have no idea on how i could do something like that as i have never tried making a game like this, I have also searched online but I dont know if it's my choice of wording that it never shows anything or if there isnt anything like it.
I have 7 column on the top, with a hairline where you touch in order to drop the tile to the grid. Right now the tiles just stack on each other.
Not sure if my response is worth to be an answer but what the heck...
If you are set on not getting into Sprite Kit right now, you could probably use UIButton to make this happen. Divide your screen into a grid of UIButtons. You can set the button images according to empty and played (red or blue). Each button code would have to check for things like if the hole (button) was already played, what color chip to display, is this a winning move, etc... There is of course an easier way to do this instead of copying the same code into each button but I'll let you try to figure that one out for now.

Using PageViewController for a large number of pages like camera roll image view?

I am trying to create an app for which I need a way to swipe through views. For example, while swiping through images in photo stream or camera roll. I DO NOT need to swipe through images however, I need to swipe through UIViews. I have been looking at PageViewController. However, setViewControllers:direction:animated:completion: suggests that I need a ViewController for every UIView. This doesn't seem to be what I want since I will have over 40 views that I will need to scroll through. I think I'm missing an obvious ios feature here since even iBooks has a way to go through pages of books.
I was thinking maybe having 3 ViewControllers and changing their content whenever I swipe across. But that seems very roundabout.
Please help me out!
Thanks!
Apple has provided a fairly robust example of doing this kind of thing with photos called "PhotoScroller" at http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html. It uses UIScrollViews and CATiledLayers to recreate the experience of the Photos app. You may be able to modify it to work with your UIViews instead of images.

Resources