6

UITabBarControllerを使用するアプリがあり、タブバーコントロールの後ろから上にスライドする必要がある別のビューがありますが、タブバーのコンテンツの前にあります。それが明確でない場合は、タブバーボタンを除くすべての前に表示されるタブ付きアプリで広告が上にスライドすることを想像してみてください。

これまでのところ、このようなコードがありますが、これを行うためのより良い方法があれば、変更したいと思います...

tabBarController.viewControllers = [NSArray arrayWithObjects:locationNavController, emergencyNavController, finderNavController, newsNavController, nil]; 

aboutView = [[AboutView alloc] initWithFrame:CGRectMake(0, window.frame.size.height - tabBarController.tabBar.frame.size.height - 37 ,
                                                        320, window.frame.size.height - tabBarController.tabBar.frame.size.height)];


[window addSubview:tabBarController.view];    // adds the tab bar's view property to the window
[window addSubview:aboutView]; // this is the view that slides in
[window makeKeyAndVisible];

現在、aboutViewはUIViewのサブクラスであり、下部の開始位置にありますが、tabBarControllerを非表示にします。これを変更してタブを上に表示し、aboutViewを他のコンテンツの前に配置するにはどうすればよいですか?

4

1 に答える 1

2

UITableBarController の現在アクティブなビュー コントローラーのビューのサブビューとして aboutView を追加する必要がありますselectedViewControllerプロパティを介してそのビューにアクセスできます。

aboutView 実装にコードを追加して、表示時にビューをアニメーション化できます。

タブバーコントロールの下に表示したいポップアップビューでこのようなことをします。aboutView 実装のdidMoveToSuperviewメッセージにコードを追加できます。

- (void)didMoveToSuperview
{
    CGRect currentFrame = self.frame;

    // animate the frame ... this just moves the view up a 10 pixels. You will want to
    // slide the view all the way to the top
    CGRect targetFrame = CGRectOffset(currentFrame, 0, -10);

    // start the animation block and set the offset
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5]; // animation duration in seconds
    [UIView setAnimationDelegate:self];

    self.frame = targetFrame;

    [UIView commitAnimations];  
}

そのため、aboutView が選択したビュー コントローラーのビューに追加されると、自動的にアニメーション化されます。

于 2011-03-16T22:13:18.490 に答える