开发者

Is it possible in ios to have the navigation bar stay as in rather then moving through the view hierarchy on click?

Is it possible in ios to have the navigation bar stay as is, in rather then moving through the view hierarchy on click? What I want is a standard 5 button navigation and when I click on an item it gives me a view transition and highlights the navbar item without changing the nav bar by moving it down the hierarchy. apologies if this is a stupid que开发者_如何转开发stion.


Sure, you could do this, but you're effectively rolling your own UITabBarController. If you haven't already, read it's class reference. You can place the tab bar at the top of your screen if that's what you want. See this question.

If you still want to create your own version with the Navigation Bar, then don't use a UINavigationController. Instead you could use a UIViewController subclass with a Navigation bar, and a UISegmentedControl. The UICatalog Sample code project shows how to implement this.

Then in the IBAction for your segmented control, do something like this:

- (IBAction)segmentChanged:(id)sender {

int selectedIndex = [sender selectedSegmentIndex];

switch (selectedIndex) {
    case 0:
        NSLog(@"segment 0 selected");
        //perform transition and switch views here
        break;
    case 1:
        NSLog(@"segment 1 selected");
        //perform transition and switch views here
        break;
    case 2:
        NSLog(@"segment 2 selected");
        //perform transition and switch views here
        break;
    default:
        break;
}  
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜