Search code examples
iphonefacebookscrollthree20horizontal-scrolling

How to manually slide to specific item in TTTabStrip (put selected to the center or make content offset)


So question is: How to manually slide to specific item in TTTabStrip (put selected to the center or make content offset)


@interface TTT : NSObject {
  TTTabStrip* _slider;
}

@implementation TTT

_slider.selectedTabIndex = index;

//This will select item in TTTabStrip view, and if item is out of screen, it wount be shown on _slider view display. What is need is to set content offset to the internal scroll view.

So main strategy is to offset selected item to the center of _slider view.


Solution

  • Other way is take subviews from TTTabStrip and if it is UIScrollView then it is our object.

    @interface SomeClass : UIViewController <UIScrollViewDelegate> {
       TTTabStrip*    _slider;
       UIScrollView*  _sliderScrollView;
    }
    
    @property (nonatomic, retain) IBOutlet TTTabBar* slider;
    
    @end
    
    @implementation SomeClass
    @synthesize slider = _slider;
    
    .......
    
    - (void) someMethod {
            for (UIView* internalView in self.slider.subviews) {
                    if ([internalView isKindOfClass:[UIScrollView class]]) {
                            _sliderScrollView = [internalView retain];
                            _sliderScrollView.delegate = self;
                    }
            }
    }
    
    @end