UIScrollView like Twitter app for iPad

后端 未结 2 1875
不思量自难忘°
不思量自难忘° 2021-01-31 12:50

I\'m looking for a tutorial or for some ideas to make a custom controller that looks like the one in the Twitter app for iPad, I mean the stacked pages with a main menu on the l

相关标签:
2条回答
  • 2021-01-31 13:17

    we had created a mock project and added in github

    https://github.com/raweng/StackScrollView

    0 讨论(0)
  • 2021-01-31 13:29

    I have a solution for this.

    Place a table view as a sidebar menu on the left side. Place a scroll view on the top. Add content into scroll view.

    The scroll view will cover the table view. Set the width of content size of the scroll view to the sum of the content width and the sidebar width. The content position is at ( sidebar width, 0 ). You could drag it to cover or reveal the sidebar.

    The problem is the table view could not receive any touch event for it is covered by the scroll view.

    So I implement a subclass.

    @interface UICascadeScrollView : UIScrollView {
            UIView* passthroughView_;
    }
    
    @property(nonatomic,assign) IBOutlet UIView* passthroughView;
    
    @end
    
    @implementation UICascadeScrollView
    
    @synthesize passthroughView = passthroughView_;
    
    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
            for( UIView* v in self.subviews ) {
                    if( CGRectContainsPoint( v.frame, point ) ) {
                            // one of the sub view could accept the touch event
                            return [super hitTest:point withEvent:event];
                    }
            }
            CGPoint newPoint = [self convertPoint:point toView:passthroughView_];
        return [passthroughView_ hitTest:newPoint withEvent:event];
    }
    
    
    - (void)dealloc {
            self.passthroughView = nil;
        [super dealloc];
    }
    
    
    @end
    

    Change the scrollview class to UICascadeScrollView and set the passthroughView to sidebar.

    That's all.

    ==================================================================================

    A sample of three cascade layers with a table view as a sidebar.

    git@github.com:slavikshen/CascadeScrollView.git

    https://github.com/slavikshen/CascadeScrollView

    This is my first commit to git hub. Pls tell me, if there is anything wrong.

    0 讨论(0)
提交回复
热议问题