hons82 / THSegmentedPager

Simple plugin-sample using the HMSegmentedControl and a UIPageViewController to show Tabs
Other
219 stars 52 forks source link

Quick Question #5

Closed bigbadleroybrown closed 9 years ago

bigbadleroybrown commented 9 years ago

Is it possible to have 4 different tableview controllers with different data sources in the segmented control?

Thanks!!

hons82 commented 9 years ago

Sure... actually that's the whole idea of the control :-D

Check out the Sample and look 4 this part of code

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    THSegmentedPager *pager = (THSegmentedPager *)((UINavigationController *)self.window.rootViewController).topViewController;
#ifndef LOAD_WITH_IDENTIFIERS
    NSMutableArray *pages = [NSMutableArray new];
    for (int i = 1; i < 4; i++) {
        // Create a new view controller and pass suitable data.
        SamplePagedViewController *pagedViewController = [pager.storyboard instantiateViewControllerWithIdentifier:@"SamplePagedViewController"];
        [pagedViewController setViewTitle:[NSString stringWithFormat:@"Page %d",i]];
        [pagedViewController.view setBackgroundColor:[UIColor colorWithHue:((i/8)%20)/20.0+0.02 saturation:(i%8+3)/10.0 brightness:91/100.0 alpha:1]];
        [pages addObject:pagedViewController];
    }
    [pager setPages:pages];
#else
    [pager setupPagesFromStoryboardWithIdentifiers:@[@"SamplePagedViewController",@"SamplePagedViewController",@"SamplePagedViewController"]];
#endif
    return YES;
}