iOS UIView/UIScrollView overlay with zoom capability - ios

I have a UIView/UIScrollView with non rectangular sections, let's call them room plans.
The UIView/UIScrollView should be zoomable.
When the user clicks to a non rectangular region/room, I should be able to detect which region was clicked and let's say open up the detailed floorplan of that particular room.
The problem is that
1. when I zoom in and out, the 'button' size must change.
2. the button is not rectangular.
see an example of what I am trying to implement in iOS.
http://www.occc.net/ifp/
Any ideas of how to approach this problem are welcome.
Thank!

I was trying to do a similar thing there. What i did was use a UIImageView within a UIScrollView and load the image in the UIImageView.
I did this in my viewDidLoad :
scrollMap.minimumZoomScale=1;
scrollMap.maximumZoomScale=2.0;
scrollMap.delegate=self;
Then added this function :
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.imgMap;
}
This made the image inside the scrollview zoomable with the aspect ratio of the scrollview. It worked for me. You can try, this might work for you too.
Thanks.

you can use OBShapedButton, i found on github and i have used in more than three apps.
It is very easy to implement you should try this.....

Related

iOS Disable scroll for map view ONLY while zooming

I am currently trying to look for a solution for disabling scrolling on a MKMapView while a person is zooming in/out. Does anyone know of a solution to this? Thanks!
I would check out this control which keeps the map centered on a point when zooming and it sounds like it should be able to achieve you desired effect. I'm not sure if you're using Objective-C or Swift since there is no tag, however you will be able to use this with either languages.
SKMapsCenter

How to limit panning and zooming in-out area?

in my app i am having one image view which contains the picture of user taken from either camera or phone library(album).And the user is allowed to select some product from a list of products for trying on his picture. I am able to do all this stuff and also i am able to do the panning, zooming and also rotation on the product. But my problem is, when i am moving this product it is going out of the image view that contains the users picture and same thing happening with the zooming ..Please help me through this..Thanks in advance..
You need to restrict it in the frame of outerview.
so CGRECT methods can serve your purpose.
such as
CGRectIntersectsRect
CGRectContainsPoint
for reference see this
and for zooming purpose see this

How to draw inside a view in a UIScrollView or UIViewVontroller?

I want to implement a signature feature in my tabbar application. I want to add a subView to a UIScrollView or UIViewController (which ever is the more appropriate and easier). Which control should I use for it?
I want to pick the touch events on the signature view and draw on those points to get the signature. Any help would be highly appreciated.
You can use just a UIView for drawing points get touched. I needed to implement something like that and the following page was really helpful. It explains all with code. You may want to check it out.
http://www.effectiveui.com/blog/2011/12/02/how-to-build-a-simple-painting-app-for-ios/
First thing you need to read is this - http://developer.apple.com
and check this apple demo - GLPaint
after that you may check this - tutorial

Adding Custom Image on Mkannotationview, or on callout bubble?

i'm trying to reproduce the kind of map behavior of the app "Stuck On Earth". Here's a screenshot :
Here's the behavior :
On the map, as you can see there is pin
When you click on a pin, it display the picture attach to it. Really important : the picture stai with the pin, and it stays BEHIND it
If you click on the picture, a new controller is called
if you click on the pin, the picture disappear
I'm trying to do something similar. For now, as i can read, i've got two solutions :
Using callout : callout is HELL. I can try to use a false annotation, but MapKit deals with the depth of elements, and the picture is always in front of the pin
Using Custom Annotation : i was going for the plan of making custom annotation view, when the pin is tapped, i launch a method of the CustomAnnotationView, adding (or removing) the thumbnail.
I think the method number 2 could work, but i've got no idea how to deal with the touch on the thumbnail.
Any suggestions or help on this ?
Thanks you !
Updated 2016-09-02:
My colleague devised an workaround by making popup views as subview of the view container which contains the map view. The position can be calculated according to the CGPoint transform in different reference systems.
Original Answer:
I also got this kind of problem, after following the tutorial 'Building Custom Map Annotation Callouts – Part 1', the interaction becomes difficult.
Have you tried the tap gesture recognizer? I added it to a subview, it works, although the code smell bad.

After rotation strange behaviour with UIScrollView

I have an iPad application and in one of my views i use UIScrollView and UIPageControl together to navigate between views array. when my simulator is on Portrait mode there is no problem but when i rotate it to Landscape just down side of the scrollview appears and i can see just about 30 per 100 of the whole view. How can i fix this situation can anyone help?
EDIT : I dynamically add some buttons-subviews on the subview that i have added to Scrollview, can some one give any idea about how to detect the orientation of the device and decide the frames. I need something like the pseudo below:
if(device_orientation == landscape){
subButton.frame=....;
textfield.frame=...;
}
else{
subButton.frame=....;
textfield.frame=...;}
}
i tried but i got black screen..
EDIT-2
I used Interface builder for some views and there are some dynamically created views.I played a little with Autoresizing properties on the .xib file and now it looks perfect but the dynamic ones(they are all objects of a subclass of UIButton) dont response to any code(resizing, bacground color-photo ect..)
Are you using interface builder or creating your view programmatically?
It would be helpful if you could post some more of your source or some screenshots so that we can see a bit more clearly what's going on. As a stab in the dark, you might want to try setting the 'autoresizingMask' property of the views which you want to resize to '~UIViewAutoresizingNone' (not-none/flexible). If you can provide some more details, I'll try to help you some more :)

Resources