タブバーを上部に配置したかったのです。
だから私はXCodeで新しいプロジェクトを作成しました。ビューを追加し、そのビュー内に追加しました(スクロールバー、テキスト、および別のビュー)。写真を参照してください。
私が欲しかったのは、タブバーを一番上に置くことでした。次に、中央にタブ バーのコンテンツが表示され、その下に小さな著作権テキストが表示されます。写真を参照してください。
これを正しく行う方法がわかりません。その場で UITabBarController を作成し、それを上部のビューに割り当てようとしました。(タブバー専用の画像の上部の空白)。
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
これを機能させるために何が欠けていますか?すべてのタブがスクロール可能になるように、コンテンツがスクロールビューに表示されるようにしました。