I have UIView that open with a UIButton click. I want to disable user interaction of all other superviews except to this specific view and his subviews, how can I do that? Just to make this view the only view that will response to user touch.
Thanks!
Agree with the comment, you probably want to disable all siblings of a view... (edited so you can set them back to enabled at some point)
- (void)setSiblings:(UIView *)view enabled:(BOOL)enabled {
for (UIView *sibling in view.superview.subviews) {
if (sibling != view) sibling.userInteractionEnabled = enabled;
}
}
I know you already accepted an answer but a better (and easier) approach is to display the new view full screen. Make the new view with a clear background. Then add the real view as a subview to this full screen view. This way you don't have to mess with any existing views to display this new view. You can still see everything behind it but touch events are blocked by the clear, fullscreen view.
Then when you remove this full screen view (fade out animation?) you don't have to mess with all the existing views again.
You shouldn't have to modify existing views just to display another. And what happens if one of those existing views really should have its interaction disabled? You will end up enabling the interaction when you dismiss your "modal" view.
Related
I have a side menu which is impelemented by SWRevealViewController and my frontView has a collection view.
SWReveal works fine by tap on menu button, but the pen gesture is not working on collection view (which has a horizontal scrolling enabled).
can any one help me to force collection view to accept the pen gesture of the SWReveal?
SWRevealViewController's gesture controller and collection view are been clashing that's why the problem occurs. Other than that as per my view there is no practical way to identify what user wants to open by the gesture.
But Client needs a solution and the image shows it! keep user interaction ON of the view.
Let me know if you find anything else.
Best of luck.
Add below code in viewDidLoad
self.view.addGestureRecognizer(revealViewController().panGestureRecognizer())
Basically, I want to be able to click all the Subviews in the Image below...
I want to be able to tap the Subviews of View B but View A is in the way even though View A Subviews are not blocking the views below. Is this possible? In other words I want to be able to tap through the transparent parts of a view even though its frame/bounds cover that area. View B is under View A in a ScrollView.
thanks,
austin
The solution is to subclass View A (if it's not a custom view already) and override pointInside:withEvent.
Return YES if the specified point is inside one of View A's sub-views, or NO otherwise. When pointInside:withEvent returns NO the system will continue to try other views until it finds one that claims the point is inside it, then it will call hitTest:withEvent to see which inner-view to send the touches to (the default behaviour).
User taps control and a different view comes up, animated. VoiceOver still highlights the removed control and it is stuck. User can't interact with the view.
This is not in a UIViewController but a custom UIView subclass.
How to tell VoiceOver to update its presentation or state when something appeared or disappeared with animation?
You can post an accessibility notification to indicate that the layout or the full screen of content has changed and select a new element.
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification
elementToSelect);
I have a custom view covering entire screen in iPod touch. I need to put add another view in this which will initially be hidden but will come on screen when view is scrolled down. I hav achieved this but not I can scroll my view to upside also. I so not want user to pull up the custom view. I just want a pull down feature and no pull up.
When someone pull down I am bringing the view to original position programatically. So, when user pull down they can see some information for 5 secs and then view is back to original position.
Hoe can I restrict my UIScrollView from being scrolled towards up on manual interaction?
I did this by following code. Its working now.
(void)scrollViewDidScroll:(UIScrollView *)iScrollView {
// Refrain the view from scrolling up
if (iScrollView.contentOffset.y > 0.0) {
iScrollView.contentOffset = CGPointZero;
}
}
I'm trying to simulate a UIAlertView behavior. Basically I want to present a view and disable the user interaction of all other views on screen (besides the presented view). How would I go about doing this?
Your pretend alert view should consist of two views. The first one is the size of the screen and has userInteractionEnabled set to YES. This prevents any touches going through to the views underneath. You then add, as a subview of this view, your actual alert window, with whatever buttons etc. you like.
You can contain both of these in a new UIWindow which you can set the windowLevel on to ensure they are on top of anything else in the screen.
You can also add a very slight backgroundColor to the screen-sized view which will dim everything behind it, if that is appropriate for your interface.
I would recommend adding a view (with user interaction disabled) with black background with an alpha of 0.3 to the applications' main window whenever you show your custom alert. This, in addition to preventing user interaction, also adds that subtle darkening effect to the UI behind your custom alert view.
Call [view setUserInteractionEnabled:NO] on all the views you want user interaction to be disabled. Don't forget to call [view setUserInteractionEnabled:YES]; on them again before you dismiss your custom alert view.