I wanted to have the tab bar at the top.
So i created a new project in XCode. Added a view and then inside that view i added (scrollbar, text and another view). See picture.
What i wanted was to have my tab bar at the top. Then in the middle would be the contents from the tab bar and below it a small copyright text. See picture.
No idea how to make this correctly. I have tried to create the UITabBarController on the fly and then assign it into the view at the top. (Top white space on the picture dedicated for the tab bar).
Here is my code to init the MainWindow.
MainWindow.h
#import <UIKit/UIKit.h>
@class Intro;
@interface MainWindow : UIViewController
@property (strong, nonatomic) IBOutlet UIScrollView *mainContentFrame;
@property (strong, nonatomic) IBOutlet UIView *mainTabBarView;
@property (strong, nonatomic) UITabBarController *mainTabBar;
@property (nonatomic, strong) Intro *intro; // Trying to get this tab to show in the tab bar
@end
MainWindow.m
#import "MainWindow.h"
#import "Intro.h"
@interface MainWindow ()
@end
@implementation MainWindow
@synthesize mainContentFrame = _mainContentFrame;
@synthesize mainTabBarView = _mainTabBarView;
@synthesize mainTabBar = _mainTabBar;
@synthesize intro = _intro;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
_intro = [[Intro alloc] init];
NSArray *allViews = [[NSArray alloc] initWithObjects:_intro, nil];
[super viewDidLoad];
// Do any additional setup after loading the view.
_mainTabBar = [[UITabBarController alloc] init];
[_mainTabBar setViewControllers:allViews];
[_mainTabBarView.window addSubview:_mainTabBar.tabBarController.view];
}
- (void)viewDidUnload
{
[self setMainTabBar:nil];
[self setMainContentFrame:nil];
[self setMainContentFrame:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
What am i missing to get this to work? Wanted the content to end up in the scrollview so that all tabs are scrollable.