Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-09-2011, 08:22 AM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 14
arbi is on a distinguished road
Unhappy NavigationController in modal view

Hi,

I've got a modal view which must have a kind of subnavigation. I tried to use a UINavigationController to realize it:

- (void)viewDidLoad
{
[super viewDidLoad];

TestSubviewLeft *leftview = [[TestSubviewLeft alloc] initWithNibName:@"TestSubviewLeft" bundle:nil];
leftview.title = @"Leftview";

TestSubviewLeft *rightview = [[TestSubviewLeft alloc] initWithNibName:@"TestSubviewRight" bundle:nil];
rightview.title = @"Rightview";

NSArray *views = [[NSArray alloc] initWithObjects:leftview, rightview, nil];
_subNavigationController = [[UINavigationController alloc] init ];//WithRootViewController:leftview];
[_subNavigationController setViewControllers:views];

[self.view addSubview:[_subNavigationController view]];
}

The problem is, that my modal view now starts with the second subview (not the first) which has a correct back button. When I click the back button, the first subviews appears, but without a "forward-button" on the right side.

What am I doing wrong?
Thangs for your help.
arbi is offline   Reply With Quote
Old 09-09-2011, 08:50 AM   #2 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 18
glogic is on a distinguished road
Default

Im new to this myself but should you not just add the left view to the controller on its own and then else where in your code have something that creates the right view and pushes it to the navigation controller stack when needed?
you can add a button to the right of the first view nav bar with something like this

Code:
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Right"
    style:UIBarButtonSystemItemDone target:nil action:nil];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];
and then within the ibaction for that button have

Code:
TestSubviewLeft *rightview = [[TestSubviewLeft alloc] initWithNibName:@"TestSubviewRight" bundle:nil];
rightview.title = @"Rightview";
 [self.navigationController pushViewController:rightview animated:YES];
    [rightview release];
glogic is offline   Reply With Quote
Old 09-09-2011, 09:02 AM   #3 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 14
arbi is on a distinguished road
Default

Quote:
Originally Posted by glogic View Post
Im new to this myself but should you not just add the left view to the controller on its own and then else where in your code have something that creates the right view and pushes it to the navigation controller stack when needed?
you can add a button to the right of the first view nav bar with something like this

Code:
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Right"
    style:UIBarButtonSystemItemDone target:nil action:nil];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];
and then within the ibaction for that button have

Code:
TestSubviewLeft *rightview = [[TestSubviewLeft alloc] initWithNibName:@"TestSubviewRight" bundle:nil];
rightview.title = @"Rightview";
 [self.navigationController pushViewController:rightview animated:YES];
    [rightview release];
Thanks for your quick answer. I first implemented it by my own navigation bar. But than I'm losing the arrows at the bar buttons. They look like normal buttons
I'm really confused by the navigation controller. If I implement as you suggestet, why do I need the navigation controller
arbi is offline   Reply With Quote
Old 09-09-2011, 09:15 AM   #4 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 18
glogic is on a distinguished road
Default

i think that the navigation controller only handles the back button functionality for you as its just a stack but you need to add extra functionality to push new views onto that stack. Now my understanding could be well off so dont shoot me if im wrong :P
glogic is offline   Reply With Quote
Old 09-09-2011, 09:31 AM   #5 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 14
arbi is on a distinguished road
Default

Quote:
Originally Posted by glogic View Post
i think that the navigation controller only handles the back button functionality for you as its just a stack but you need to add extra functionality to push new views onto that stack. Now my understanding could be well off so dont shoot me if im wrong :P
Maybe you're right - unfortunately. So I want to explain agein what I need:
I need a submenue to switch between two subviews. And the buttons on the navigation bar should have this style with arrows on the left or right side.

Is this possible without painting special background images?
arbi is offline   Reply With Quote
Old 09-09-2011, 09:33 AM   #6 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 18
glogic is on a distinguished road
Default

just seen you can set the style of the button when you create it youself so you can maybe get the button type you want?
Loading…
glogic is offline   Reply With Quote
Old 09-09-2011, 09:40 AM   #7 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 14
arbi is on a distinguished road
Default

Quote:
Originally Posted by glogic View Post
just seen you can set the style of the button when you create it youself so you can maybe get the button type you want?
Loading…
Yes, I know that, thank you. But there's no style for forward or back
arbi is offline   Reply With Quote
Old 09-09-2011, 10:07 AM   #8 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 18
glogic is on a distinguished road
Default

not sure if this will help as im not sure how you could add it to the nav bar but

Code:
UIButton *t = [UIButton buttonWithType:101];
    [someview addSubview:t];
will give you an arrow button. then scale it with -1 in x direction for right facing. Im not able to check if any of that will work at the moment but might be worth having a look at yourself
glogic is offline   Reply With Quote
Reply

Bookmarks

Tags
navigation submenue

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 413
11 members and 402 guests
apatsufas, Eclectic, fiftysixty, JackReidy, jeroenkeij, Sami Gh, teebee74, tim0504, UMAD, yomo710, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:59 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0