How to add bookmark in iPhone application? - iphone

I have large image which is placed in UIImage with in the UIScrollView. I want to put Bookmark any particular point of image. How it is possible?
My App Structure
ScrollView
-ImageView
-TestImage.png
Thank you.

A couple of approaches:
1) Composite the bookmark image directly onto your UIImage and update your UIImageView in your scroll view.
2) Add an overlay of your image as a view on top of the UIImageView. This is probably easist approach. In this approach, just get the touches point and create a new UIImageView containing the bookmark and addSubview it in the touches center point (or workout if the image is a pin, where the bottom of the pin should hit on the image).

Related

Adding UIButton to UIImageView within UIScrollView on Swift

I am writing an application for an event my organization is hosting using Swift. I have an image with the floor layout and want to add buttons to select locations (such as bathrooms, entrances, exits, emergency sections, etc) so that people can click them and information about the location pops up.
I currently have an imageview with the floor layout within a scrollview to allow the user to zoom in and out of the image. When I try to add buttons to the scrollview they don't stay relative to the image when zooming in and out, nor do their size change. I have tried adding constraints on to make the location stay the same when zooming in and out.
It also won't let me relocate the button on the storyboard to be a subview of the imageview. Looking up similar solutions says to add the button programmatically as a subview of the imageview but then it'd be really hard to put the 100+ buttons in the right location. Any suggestions as to how to go about this?
you have no other choice instead of adding by code.. because from code you can add as subview of image view , whereas Storyboard wont add buttons as subviews of imageView, but it will add buttons as subview of Scroll View

how to drag an uiimage from scrollview to another uiimageview in iphone sdk

In My Application,i am having one scrollVIew containing multiple images.
and out of the scrollview i have one uiimageview.
i want to Drag any image from ScrollView and drop it on uiimageview which is out of the scrollview.
is it possible?
help And suggestions are appreciated
Thanks in advance.
gamozzii's reply is close to what you need to do, but there's one problem. An UIScrollView will eat touches, so tapping on an image will have no effect.
As a result you will have to subclass the UIScrollView
I have written a small functional app to illustrate dragging the image from a scroll view into an image view. You can download the project here.
Yes this should be possible, you will need to implement the touch/drag events directly.
Check out the touchesBegan, touchesMoved etc. delegate methods in UIResponder.
One approach would be to subclass imageview and implement touchesBegan, touchesMoved in it, and use this imageview subclass to display your images in the scroll view.
On the touchesBegan create a new image view and add it to the outer view and set its image to be the same as the one in the scroll view. You need to overlay it directly over your source image in the scroll view so adjust its frame origin to be relative to the outer view you will need to use the scrollview origin and also the content view size and offset of the source image view inside the content view in order to recalculate the new origin in the outer view.
Then on the touches moved, simply readjust the frame of this image in accordance with the coordinates from the touches moved so that the image follows the touch.
Do a boundary check against the frame of your target imageview - once the user drags it into this boundary, make that target imageviews image the same as the image in the view being dragged and remove the dragged image from the containing view and release it.
In case you're still interested in another solution (and for other users of course):
I did implement that behaviour before just like gamozzii recommended.
I set canCancelContentTouches = NO on the UIScrollView to make sure the subviews handle there touches on their own. If a subview (in your case an image) was touched, i moved the view out of the scrollview onto the superview and started tracking it's dragging. (You have to calculate the correct coordinates within the new superview, so it stays in place). After dragging finishes, i checked if the target area was reached, otherwise I moved it back into the scrollview.
The subviews are handling the dragging on there own via (touchesBegan:/Moved:/Ended:/Cancelled:).
If that's not detailed enough, here's my example code: Github: JDDroppableView

Dragging an image and leaving it where it was dragged on the iphone

I have a map image and I would like to be able to drag the image somewhere on the screen and then be able to go get another image from a webserver with the new map image being where the old image was dragged.
I've tried the UIImageView in a UIScrollView but the image is bounced back to fill the screen if I try to drag it off. Setting the UIScrollView .bounces = NO isn't what I need either because that just prevents me from dragging the image off of the screen. Is there an easy way to get this functionality?
I think you want to look at the UIResponder methods touchesBegan, touchesMoved and touchesEnded.
I ended up using UIPinchGestureRecognizer and UIPanGestureRecognizer to do this.

Setting up the (right) views in order to show an image, the details of it beneath it and enable zooming for the image

What I am trying to do is to present an image at the top of the view and beneath it to show the details of it.
By now I am using a UITableView and a UIImageView. The UIImageView is at the top of the View and the UITableView beneath the UIImageView. In the UIImageView I load an image and I want to let the user to pan/zoom it. In the UITableView I show in sections the details of the image. Everything works ok, but when I enable zooming in the UIImageView the image covers parts of the tableView. Moreover, I cannot scroll anymore.
What is the correct combiantion of views for achieving the above requirements?
Instead of the UIImageView I'd use a UIScrollView with the UIImageView embedded in it, this will allow you to setup pan/zoom within whatever view size you want.

UIImageView, UIView, taking a segment of a picture

I want to take an image from the UIImagePickerController and put it on a UIImageView that can move based on touch. I'm not sure how to get the picture onto the UIImageView. I thought the UIImageView automatically resizes the picture, so I couldn't grab just the top half of the picture and put that on the UIImageView. Is there an easy way to do this? thanks!
Use CGImageCreateWithImageInRect to crop (take a segment of?) a picture. Put a UIImageView inside a UIScrollView to let the user scroll through (move based on touch) a large image.
if you want to move and zoom your picture in a view, you need to use a UIScrollView. See Apple's ScrollViewSuite example. If you simply want to position the picture within a UIImageView, set the contentMode of the UIImageView to the setting you want e.g. scale, top, left, etc. See the UIImageView documentation for all options.