0

UIViewController 内に UIScrollView を作成しました。そして今、それに UITabBarController を追加したいと思います。

私はこのコードを書きました

[testscroll setScrollEnabled:YES];
[testscroll setContentSize:CGSizeMake(320,800)];
FirstViewController *first = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
first.title=@"Search";
UserProfile *second=[[UserProfile alloc]initWithNibName:@"UserProfile" bundle:nil];
second.title=@"My Profile";

UserActivities *third=[[UserActivities alloc]initWithNibName:@"UserActivities" bundle:nil];
third.title=@"My Activities";
LogOut *logout=[[LogOut alloc]initWithNibName:@"LogOut" bundle:nil];
logout.title=@"Sign Out";
NSArray *viewArray= [NSArray arrayWithObjects:first,second,third,logout, nil];
tabBarController=[[UITabBarController alloc] init];
[tabBarController setViewControllers:viewArray animated:NO];
[self presentModalViewController:tabBarController animated:NO];  

私はこれを5番目のViewControllerに追加しました。UIScrollViewといくつかのラベルとテキストフィールドが追加されていますが、TabBarControllerは追加されていません。

4

1 に答える 1

0

私が見る限り、あなたはタブバーコントローラーを作成し、それをモーダルに提示しています。

NSArray *viewArray= [NSArray arrayWithObjects:first,second,third,logout, nil];
tabBarController=[[UITabBarController alloc] init];
[tabBarController setViewControllers:viewArray animated:NO];
[self presentModalViewController:tabBarController animated:NO];  

scrollView2つを「接続」していないため、表示されません。

タブバーコントローラーをスクロールビュー内に表示する場合は、スクロールビューにサブビューとして追加します。

[testscroll setScrollEnabled:YES];
[testscroll setContentSize:CGSizeMake(320,800)];
...
[testscroll addSubview:tabBarController.view];

tabBarController(これはプロパティであり、スクロールビューが何らかの方法で表示されると想定しています)

于 2012-11-04T09:40:03.853 に答える