I added a UIImageView as a subview to my UIView and then I added a transparent UIView to my view.
Now, the transparent view is the topmost view. But i would like to use Pan, Pinch, rotate gesture on my uiimageView.
The transparent view will have some text message to the user or some grid line to indicate the user to perform some tasks like image rotation, shrink and move etc..
For now, the transparent view is blocking all my gestures.
How can we make the gestures recognized by the UIImageView by overriding the topmost UIView gesture recogniser ?
[yourView setUserInteractionEnabled:NO] - this way all touch events on that view will be ignored and the next one in the view hierarchy will respond to them.
Related
I have been working in a project which has a uiscroll view where the uiscroll view size is set programatically with height 225 and width is self. I have created two uiimageView where it displays two images and I have animated it by moving using a page view controller. Finally the image moves atomically like a slide show with page view controller. I have removed the navigation controller do I need to keep a back button for navigation when I place a unbutton above uiscrollview it was stating like scrollview ambitious scrolling content. I need to place a rounded back button above scroll view. I have attached the image of my storyboard. When I tried to place a button it is not visible in stimulator header scroll view is the UISCROLLVIEW where the animated image is placed
I need to create a custom view for scroll the UITableView/ ScrollView.
Here I attached the picture,
While scroll the color I need to scroll the tableView and up/down arrow button press also the same function.
How can I implement the scroll.
Create a UIView subclass that has controls for moving the page and the scroll bar.
Then you can update the scroll bar from the scrollViewDidScroll method.
Similarly, when the buttons are pressed you can tell the scroll view to setContentOffset.
I have created a game where a map is on the screen. With this map I would like to have buttons to change scenes and preform actions. The map I have on the screen I would like to be the full screen with pinch zoom capability, along with capability of a button or label to be on top of the image, without the button being zoomed in on or below the scroll view. I tried using a UIScroll View but the button kept zooming in and going below the image. How can I set the background of my View to a pinch zoomable image with labels and buttons on top not being effected in swift and xcode 7?
I am not sure if this is the most efficient way, but by calling the method touchesDidBegin() you can move the objects like the TextField and the buttons to a new view that is above the scrollview. Then when touchesDidEnd() you can move them back into the scrollview.
I have a problem with sendSubviewToBack and bringSubviewToFront calls. I create UIImageView and ScrollView with several other elements (like buttons and labels) programmaticaly (only ScrollView is created in storyboard). UIImageView have to hold a background image. ScrollView and UIImageView are added as subviews of view controller (other elements are subviews of scrollview). After I create a UIImageView and set the image like this, I call
self.backgroundImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];
[self.backgroundImage setImage:[UIImage imageNamed:#"chooseDoctorBackground"]];
[self.view addSubview:self.backgroundImage];
[self.view sendSubviewToBack:self.backgroundImage];
After that, scroll view "moves up" and becomes overlapped by navigation bar (it doesn't happening if we won't call sendSubviewToFront). There is an easy workaround - just to define position of UIImageView and UIScrollView explicitly (using setFrame) with consideration of navigation bar and status bar height. However, I don't understand the root cause of such behavior. Could you please explain it to me?
Thanks in advance!
I came here looking for help with a similar issue, and have since figured out the cause of both our problems:
When a UIScrollView is the back-most subview of your view, iOS will auto-pad the UIScrollView's content to account for the status bar and navigation bar. That is why your scroll view's content appears fine at first.
When you call
[self.view sendSubviewToBack:self.backgroundImage];
your UIImageView becomes the back-most subview, and the UIScrollView ceases to get auto-padded. That's why the content of the UIScrollView moves up underneath the navigation bar.
You'll need to manually set your scroll view's frame or content offset to account for the status and navigation bars in order to support the background view appearing behind.
(In my experience, this auto-pad behavior on UIScrollView happens even if the y origin of the scroll view is non-zero and it sits lower on the screen, nowhere near the status or navigation bars.)
I have a UIViewController with a UIPanGestureRecognizer on its UIView, inside a UINavigationController. I need to detect vertical pans, even if they start in the navigation controller's navigation bar. At the moment, my handler method only gets called if the pan starts inside my controller's view.
How do I detect a pan gesture that starts outside my view?