Smooth update top subview while dragging one of the bottom subviews (iOS) - ios

I have a lot of small draggable subviews in my iPad app. I have also a top non-opaque subview with clear color background. It has screen size. User interaction is disabled for it. I need to redraw that top subview while I am dragging one of the bottom subviews. I draw some lines on that top subview. They have to be redrawed according with current bottom subview position. I want achieve smooth dragging but currently I can't. Currently I send a lot of setNeedsDisplayInRect to top view in panMoved of my bottom subview.
How to do that better?

Better to use CALayer of the top subview for drawing. It's much more effective.

Related

How to handle an UIScrollView in an UIScrollView

I want to use an UIScrollView in an UIScrollView. I think it would be clearer with a
picture
The black border is the border of the screen, the purple is the first UIScrollView and the blue is the second UIScrollView. The arrows show the direction of the scroll.
When I try to put the second UIScrollView in the first with a different scrolling direction, the second show the content twice... I made a video
I have created design for you to explain how to add scroll view inside scroll view.
Here see the following image with constraints.
Note: This is static view not dynamic, This is create to clear concept of ScrollView inside ScrollView. If you are planning to make ScrollView with design then you need to do some more study on AutoLayout with ScrollView.

IOS/autolayout: Detect touch event below visible view of scrollview

I have been struggling with how to detect touches on a portion of a tall textview subview that extends below the visible view of a screen.
The view hierarchy looks like this:
View Controller
UIView (UV,visible portion of screen)
UIScrollView (SV)
UIView (CV,Content View--contains all elements)
UITextView (TV)
When the screen first loads, a portion of the textview (TV) is visible, the portion contained within the UV, or visible portion of the screen. When you scroll, you move the scrollview (SV) behind the visible portion of screen, revealing portions of the textview that are outside the original UIView (UV).
When you scroll down, while you can see the lower portions of the textview, they do not respond to touches.
Can anyone suggest a way to make an entire textview reponsive to touches even, portions of the textview that extend below the visible UIVIew?
Do I need to make UIVIew (visible portion of screen) bigger than the actual phone screen? Or what can I do.
Of note, the gesture recognizer is currently added to the view in viewdidload before views are laid out. It does adjust to changes in the view size based on quantity of text up to the UIView (UV) edge. However, it will not recognize touches below the original UV bottom edge.
Thanks for any suggestions.
In visual debugger, you can see the UIView in white and the scrollview in blue. The portion of the textview that is white--equivalent to what you see before scrolling--is touchable, while the portion in blue, visible after scrolling, is not.

UIScrollView with added another UIScrollView outside it frame not scrolling

I've created main scroll view for scrolling between pages on the screen.
It's dark gray area named scroll 1. Next, on this main scroll I've added small scroll 2(light gray area).
Currently, for scroll 2 I can touch and scroll only if touch located at
above scroll 1 area. Please check this:
Scroll 2 added at position:
CGRectMake(25, -40, 250, 85)]
So, it's half outside of frame of scroll 1.
I've set:
scroll1.clipsToBounds = NO;
But it's like clipping touches too.. I need to be able to touch scroll 2 even if it's outside of scroll 2. How this problem can be solved?
Also, main thing I need is that when I'm scrolling small scroll 2 - scroll 1 should not catch touches.
clipsToBounds only covers rendering not touch handling - it will allow your view to be drawn outside the bounds but it does not extend the touch handling.
The easiest way to achieve what you want here is to have a container view that is big enough to hold both scroll views and then add the scroll views to this container instead of adding the small scroll view to the big one.

ios set background of a UITableViewCell

If you have seen the mailbox app you can swipe cells left and right and they have a UIView underneath that like green with a checkmark or whatever. I want to do this same thing. I have a tableView with custom cells that have gesture recognizers to animate/swipe them left and right but I can't figure out how to place a background underneath them. Does anyone know how to do this?
It might work if you add the subview and then bring the cell's content view above it, and then slide the content view over.
You could also just have a mask that clips the the visibility of your button container, and then animate the size of the mask so that it becomes visible as your cell content slides away.
You would want to add the container on the swipe before the animation starts, and then remove it after the animation stops when hiding it.
If placing it beneath the content view doesn't work, then use the mask, which will.

horizontal scrolling of a scrollView in a scrollView - small problem

i have a scrollView that fits the whole screen. In that View i show some UIImages that scroll horizontally. Like in the PageControl Project from Apple.
Then, when the user taps the screen, i fade in a scrollView at the bottom with some other images. Also horizontally scrolling. Like in the ScrollView Project from Apple.
My problem is, that when i come to the end of the scrollView which was faded in, the upper scrollView also starts to drag. How can i stop that during activation of the second scrollView?
Redraw the frame limits on your first scrollView when the second enters the screen. That way, your touches won't respond to both views. This means you need a container-view to keep both views seperated from each other.
Then you just rescale it back whenever your second scrollView disappears.
Edit: or disable scroll in your first scrollview while the second is open.

Resources