1

I have a strange problem. I have 3 level of views :

- MainView
    - containerview
        - subview
            -some buttons
    -some buttons

I've made a animation to make my subview appears and disappear by clicking a button in the master view. The following is a part of the code to make the subview disappeared and reappeared :

 [UIView animateWithDuration:0.4 //begin animation
                      delay:0.1 
                    options:UIViewAnimationCurveEaseIn 
                 animations:^{
                     [UIView transitionWithView:containerview 
                                       duration:0.4
                                        options:UIViewAnimationOptionTransitionCurlUp
                                     animations:^{ [subView removeFromSuperview] ;}
                                     completion:nil];
                     containerview.alpha = 0;

                 } 
                 completion:^(BOOL finished){
                     saveButton.hidden = true;
                     saveDAVButton.hidden = true;    
                     saveDBButton.hidden = true; 
                     loadButton.hidden = false;
                     openDAVButton.hidden = false;    
                     openDBButton.hidden = false;
                     [UIView transitionWithView:containerview 
                                       duration:0.4
                                        options:UIViewAnimationOptionTransitionCurlDown
                                     animations:^{ [containerview addSubview:subView] ;}
                                     completion:nil];
                     containerview.alpha = 1;
                 }
 ];

This animation works perfectly. The only problem is that even when the subview is visible (so subview buttons as well), i can click buttons behind the subview! (buttons from the master view). That makes buttons from the subview hard to use, because they overlap buttons from masterview.

Any idea how to make element behind the subview unclickable?

I already tried to make buttons from master view disable and hidden, but even then, i can't use overlapping buttons from subview!

Thank you for your help.

UPDATE I've found what the problem is. Actually, i have again to make my post clearer. Here is the hierarchy of the views, with there position and size :

- MainWindow (0,0,768,1024)
    - MainView (0,0,768,80) (this is actually a top tool bar)
        - containerview (500,40,120,80)
            - subview (500,40,120,80) (will act as a post it : curl up and down...)

So, the problem is that the bottom of my subview is going outside of MainView. Nothing happen when a click to buttons place at the bottom of subview. In fact, i am clicking on MainWindow! Hafl of subview is unclickable...

Before changing all my code, is there a way to make accessible bottom of subview even if he is part of MainView? Or do i have to move it in MainWindow?

Thank you again...

peterphonic
  • 951
  • 1
  • 19
  • 38

3 Answers3

1

Switch the view's userInteractionEnabled property.

David Dunham
  • 8,139
  • 3
  • 28
  • 41
  • I am not at work right now, but i am wondering if this property will disable all buttons from master view? I want to disable only buttons behind the subview, so users will be able to click others buttons from master view... – peterphonic Sep 30 '11 at 23:05
  • This cascades down the view hierarchy. Bad way to do it. – Kenny Winker Oct 01 '11 at 00:08
  • Hmm, I think I misunderstood the question (perhaps the edit made it clearer?), Kenny is probably right that this isn't what you want. You could do it to a container the other buttons are in, though. – David Dunham Oct 01 '11 at 00:40
  • yes sorry, i realized that my first edit was not clear at all! – peterphonic Oct 01 '11 at 00:53
1

Possibly the problem is that your buttons from the master view are in front of the containerView. Try:

[MainView bringSubviewToFront:containerView];

Or in interface builder rearrange the order of containerView and the buttons that are in the main view.

But I don't know, setting the buttons to hidden should make them hidden and unclickable, and prevent them from blocking touches to views behind them.

morningstar
  • 8,952
  • 6
  • 31
  • 42
  • This is it. The buttons in the container view are all behind the buttons outside the container view. You can set your container view background color to 0.5 opacity to see what's in front and behind and get a better idea of the view hierarchy. – Kenny Winker Oct 01 '11 at 00:10
  • I will try this out tomorrow. But i confirm, i can't use buttons from subview overlapping buttons from master view even when disable or hidden! I also confirm that subview seems at the top, because i can see his buttons and i can't see buttons behind (from master view). Anyway, i will try bringSubviewToFront tomorrow, thanks for your help! – peterphonic Oct 01 '11 at 00:47
  • I did update again my post. I point out what the problem is, but i still need a solution... – peterphonic Oct 01 '11 at 15:43
0

Seeing your latest edit, perhaps you could check your clipsToBounds property (though getting everything to work right when things are outside a parent's bounds can be tricky — I can’t recall now but I may have given up and changed my containment hierarchy).

David Dunham
  • 8,139
  • 3
  • 28
  • 41
  • FInally, my problem was that [link]http://stackoverflow.com/questions/7622770/how-access-an-uiview-subview-partially-outside-of-his-parent-uiview – peterphonic Oct 05 '11 at 01:05