IPhone Navigation Controller Problem

I started working on learning how to use the iPhone UINavigationController in my app, and so far I have a UIViewController subclass that I can create multiple instances of with a view from a .xib file and push onto the navigation controller stack. Everything works, including the back button, but the first pushed view controller doesn't have a back button, so once I push one view on, the first view is inaccessible. Every view controller from the third one on has the back button. Any idea why?

Well, I finally solved it. Turns out I needed to give the root UIViewController a title, and all the back buttons appeared fine, with the "invisible" one gaining the title of the root controller. Interesting how the others appeared - I guess creating a UIViewController programatically without a title gives the back button pointing to it a default title of "Back".

Similar Messages

  • Asynchronous connection navigation controller problem

    Hi,
    I have a view where I download some data from my server in an asynchronous way. Here is my viewWillAppear method:
    -(void)viewWillAppear:(BOOL)animated {
       NSURL *url = [NSURL URLWithString:kAuthenticationCheckURL];
       NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
        [request setHTTPMethod:@"POST"];
        NSString *strPostData = [NSString stringWithFormat:@"device_id:%@",device_id];
        NSData *requestBody = [strPostData dataUsingEncoding:NSUTF8StringEncoding];
        [request setHTTPBody:requestBody];
        NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];
       if (conn) {
            [self.view setUserInteractionEnabled:FALSE];
            [actAuthentication startAnimating];
            receivedData = [[NSMutableData data] retain];
        } else {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:@"Connection to the server failed!" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
            [alert release];
    Now once the data is loaded and the connectionDidFinishLoading method gets called, I want to navigate onto the new view controller (depending on the data received from the server. Here is my piece of code to do this:
    - (void)connectionDidFinishLoading:(NSURLConnection *)connection{
        [self.view setUserInteractionEnabled:TRUE];
        [actAuthentication stopAnimating];
        NSString *strAuthenticated = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding];
        NSLog(@"Authentication check response: %@",strAuthenticated);
        if (![strAuthenticated isEqualToString:@"YES"]) {
             Authentication1 *vcAuthentication = [[Authentication1 alloc] initWithNibName:@"Authentication1" bundle:[NSBundle mainBundle]];
             [self.navigationController pushViewController:vcAuthentication animated:YES];
             [vcAuthentication release];
        [connection cancel];
        [connection release];
    Now if the response from the server is something other than "YES", then the new view should be pushed into the navigation controller. But that is not happening. I tried to debug and found that the new VC is created and pushed successfully but is never visible. Perhaps its something to do with the thread as I read that asynchronous calls are made in s seperate thread.
    Looking forward for some suggestions.
    Regards,
    Obaid

    One more thing, I tried to check if the control really reaches the viewDidAppear and viewWillAppear methods of the new view (i.e. Authentication1)and it successfully reaches both these delegate methods of the new view. It means that somehow the new view is being created and pushed succesfuly but don't know why its not visible.
    Regards,
    Obaid

  • Problem responding to view being popped from navigation controller

    I have a detail view controller which is pushed onto the application's navigation controller stack by a given parent controller. The user is able to select table values in the detail controller, which should update the parent controller when, and only when, the detail view is popped and the parent view is made visible again.
    Is there a way to do this? I couldn't see any appropriate methods in UIViewController which would be called when the child view is popped. I've tried to make the parent controller conform the UINavigationControllerDelegate protocol and provided an implementation for willShowViewController method, but this method doesn't seem to get called when the view is displayed.
    I'm not sure if I'm going about it the right way trying to implement the UINavigationControllerDelegate and there is a bug with my implementation, or there are better ways to go to implement this functionality, such as using a modal controller, etc.

    m_userName wrote:
    The user is able to select table values in the detail controller, which should update the parent controller when, and only when, the detail view is popped and the parent view is made visible again.
    I don't understand why you require the update to be made only when the detail controller is popped, since during the time the detail controller is on top of the stack, the controller underneath isn't visible. It's common practice to pass data to the previous controller any time before the top controller is popped. Note that there's only a short interval between the time the top controller is removed from the stack and the time it's deallocated (unless you've retained that controller elsewhere, which should be avoided for best memory management).
    That said, [viewDidDisappear:|http://developer.apple.com/library/ios/documentation/UIKit/R eference/UIViewControllerClass/Reference/Reference.html#//appleref/doc/uid/TP40006926-CH3-SW20] is called during that interval, so I think it would be a good choice for the requirement you described:
    - (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    if (self.navigationController == nil) {
    NSLog(@"%s: *POPPED* level=%d", _func_, level);
    // pass the data here
    The test for a nil navigationController pointer tells us whether the controller is actually off the stack when viewDidDisappear: runs. This is useful in case an instance of this controller class ever pushes another controller on top of it, since viewDidDisappear: will run in that situation as well. But in that case the controller doing the pushing remains on the stack, so its navigationController property won't be nil. If that property is nil when viewDidDisappear: runs, we know self has just been popped.
    You can also find the above example in [Problem with text in detailTextLabel of UITableViewCell |http://discussions.apple.com/message.jspa?messageID=12495708#12495708], so if you build the code in that thread you can see how things work together.
    - Ray

  • IPhone SDK: Navigation Hierarchy Problem

    Hello!
    I've started developing for the iPhone and read through the programming guides of the developer site.
    As my first application I've wanted to make a navigation hierarchy. When I click in the MainWindow on a button a second view is put on the navigation controller and is displayed. But when I click on a button in this appeared view the application crashes instead of displayed another view.
    Here you can find the code: [Click|http://chaossanctuary.ch.ohost.de/navigation.zip]
    Maybe someone can help me, but I don't know how to make further on.
    Thanks in advice for your answers!
    Greets

    Could you let me know as where is the xcode setting through which it is looking for the compiler in the following path ? This path is probably wrong (Pls refer to the error messages)
    I'm not sure this will be of any help to you -- I'm not sure if it's the answer you're looking for, since I don't really know enough on the subject. However, this may answer your question, or at least maybe help you find the answer for yourself, so it's worth a shot. Try going to Edit Project Settings in the Project menu, and once the Project Settings open, select the Build tab. Search through this and see if you find any preferences along the lines of what you are looking for. In particular I would try the sections toward the bottom about the GCC 4.0 compiler. Sorry if this was a waste of time, but I wanted to try...

  • [iphone beta 6] rotating with a navigation controller

    ok... this started happening in beta 6.
    i have a navigation controller. when i rotate the device to landscape, the view that it is on only gets half the screen vertically, when i rotate it back to portrait, the view only gets half horizontally.
    i have had many problems with rotating the device in the past, so it is likely that one of my workarounds i implemented then has not come back to bite me.
    manually setting the top view's frame with:
    navController.topViewController.view.frame = [self getScreenRect];
    does nothing
    any ideas?
    john
    Message was edited by: johne-dm

    just some debugging ideas.
    skip the nav controller and just have that top controller as the current view controller. see if you get the same behavior. then you know that it's not the nav controller.
    check the autoresizemask property of the top view controller's view. it should be set to expand vertically/horizontally as necessary.
    something that's helped me in the past is to set different backgroundColors for all view controller views.

  • [iPhone] - Add command to a navigation controller back button?

    I have a root navigation controller with a table view going to a normal view controller. The normal view controller plays a sound but I am wanting the sound to stop when the back button is pressed to go back to the root view. Currently, the sound will continue playing until it ends. Where do I put the code to stop the sound when the back button is pressed?
    Thanks!

    You could place it in the UIViewController delegate method - (void) viewWillDisappear:(BOOL)animated.

  • IPhone Dev: Tab Bar Controller with nested Navigation Controller

    I want to have a tab bar with 2 views. The first view is a navigational one. I know the view can be loaded in from an external nib and I can set the first view to a navigation controller.
    My question is: can this navigation controller in the external nib instead? Ideally I want to separate it out so the tab bar loads in the external nib (that has the navigation controller). Is this possible? or the only approach is to simply have to set the view controller to a navigation controller?

    Hey, this writing an app that uses the Tab View Controller in conjunction with Navigation View Controllers is driving me bats. I took a sample program which worked well, added a nib file for a basic view that only had a label on it then:
    * I created a view controller class to work with it.
    * I added code to add create a navigation controller.
    * Added my new view controller to the navigation controller
    * added this nav controller to the array with the other stuff for the tab view controller.
    * RUN
    Everything seems to work as far as all the existing stuff. And the title for my new "tab" shows up on the More tab.
    But when I click on it (in the simulator) the program crashes. It could be how I set up the nib file I made is wrong.
    I posted the code on my web site. Here is the URL:
    http://chomer.com/iphonesample_code/05a_-_Brightness_ToolbarSwatches.zip
    Please have a look. Its probably something small and stupid that I missed.
    Regards,
    Orville

  • Multi layer table view/navigation controller hierarchy best practice

    Hi,
    I am new to iPad/iPhone development and wondering what the best practice for multiple layers of table views is? I understand the principle of a navigation controller providing the framework for moving up and down a list but have not yet quite got my head around if you should have one navigation controller for the whole tree or several navigation controllers.
    In my app I need to have the following:
    Main view -> window view showing some interactive elements (picker, buttons etc.)
    Setup view -> Hierarchy managed by nav controller/table views
    The setup view needs to manage the following hierarchy...
    - Level A:
    - Global app variables (one table view)
    - Level B Items (table view showing list of items at belonging to Level B)
    - Level B Item 1 (table view showing list of items at level C belonging to level B item 1)
    - Level C Item 1 (table view showing list of items at level D belonging to level C item 1)
    - Level D Item 1 (table view showing list of items at level E belonging to level D item 1)
    - Level E item (table view for properties of item at Level E)
    - Level D Item n
    - Level C Item n
    - Level B Item n
    Each level in this has some properties and then a list of child items.
    What would be the best way of structuring this? I would assume that creating a class that extends a view controller for each level is a given but what about the control of the navigation? Should this be handled by one navigation controller or one per level? I think I know the right answer but have not seen a neat way of implementing
    I think I am also best off having each level in it's own xib but, once again, am not 100% sure that this is the best design pattern.
    Many thanks in advance for any help/pointers!
    Cheers
    jez

    Hi Julian,
    I have struggled with the same questions you are addressing. On a previous project we tried to model based on packages, but during the course of the project we encountered some problems that grew overtime. The main problems were:
    1. It is hard to enforce rules on package assignments
    2. With multiple developers on the project and limited time we didn't have time to review package assignment
    3. Devopelers would click away warnings that an object was already part of another project and just continue
    4. After go-live the maintenance partner didn't care.
    So, my experience is is that it is a nice feature, but only from a high level design point of view. In real life it will get messy and above all, it doesn't add much value to the development. On my neew assignment we are just working with packages based on functional area and that works just fine.
    Roy

  • The internal workings implicitly popping from Navigation Controller

    I'm just curious to how a Navigation Controller is working when you pop out from a child view to a parent view. The reason I'm asking is because I have this kind of set up:
    App Delegate:
    Creates Nav Controller and inits it with a Root View
    Root View:
    Just some table view that allows to drill down a row to "Second View" lets call it
    When I push the second view into the Nav's stack, it'll automatically create a back button to pop. I am noticing when I hit back, it displays the Root View but the view event methods, i.e. viewWillAppear, are not called. Why is this?
    Since this is the case, what is the best way for me to reload the table view's data when I do a pop?

    Hey Ray,
    Sorry for all the confusion previously. I didn't have my personal computer at work so I wasn't able to copy/paste the exact code snippets but I can assure you that my print logs are working correctly. I actually have figured out what my issue was and I'll present to you (and anyone else who have run into a similar problem) what my problem was and what I did to solve it.
    First of all, let me address your previous questions. I am creating my Nav controller and the root view in the app delegate via the applicationDidFinishLaunching method. So something like this:
    myViewController *vc = [[myViewController alloc] initWithNibName@"myViewController" bundle:nil];
    myNavController = [[UINavigationController alloc] initWithRootViewController:myViewController];
    This was not the issue. The issue stems from the design of my app.
    The *root view controller* is actually a view that acts as a *container for two other view controllers*. One of them a *UITableViewController that controls a UITableView*, and the other is a *UIViewController that controls a MKMapView*.
    The UITableView has the ability to drill down into another table view, which invokes some actions that updates the list from the first view. This all works fine as I'm seeing in my logs.
    The problem was when I pop back to the root view I don't see the list updated; this pop back I'm referring to is the "Back" UIBarButtonItem that gets prefabbed for me when I push something to the Nav controller's stack. From my logs, the UITableViewController's inherited method, viewWillAppear is not being invoked, therefore, the [self.tableView reloadData]; that I placed in there is not being called.
    For some reason, a light bulb went on in my head today to investigate the container's view controller! *What I found out was only the container view controller's view event methods was getting called*; so all the viewWillAppear, viewDidAppear, etc... that I did not previously implement wasn't getting called and not appearing in the logs.
    So now, in the container's view controller's viewWillAppear, I call the UITableViewController's viewWillAppear, and my UITableView's list gets updated. So it's all working perfectly now.
    Thanks!

  • [iPhone] auto-rotation problems

    I'm having a really tough time getting auto-rotation to work properly.
    My biggest problem is most of my application only works in Portrait mode, but there is one view (with subviews) and a controller that handles landscape (it displays an image). When I rotate the device to landscape mode while this view is up, then cause this controller to pop back to the previous controller (a navigation controller), the rest of the interface is now in landscape mode instead of portrait, which is messing up my other portrait only views. I expected that popping my landscape-supporting controller would revert the interface to portrait, since none of the other controllers support landscape.
    Anyone know what I'm doing wrong?
    And is there a way to "force" the device into landscape mode when a landscape image is selected? See I have a image picker controller (portrait), and when I pick a landscape image I'd ideally like to just have my image viewer (and subviews) show up in landscape mode - like how Movie Player does it.
    I know this is possible, but I haven't figured out how yet.

    I am having the same problem that you have descibed below. Did you ever find a solution? I have tried all types of possible solutions but cannot get the previous view to revert back to portrait as well.

  • UIImagePicker on a navigation controller

    hello i have a navigation controller which has 3 view controllers. the second one has 3 images and three buttons each of them goes to third view controller which has an image viewer i want the user depending the button pressed to show the appropriate image on the third view controller using the image picker. The photos are placed in an array with photos.

    Hi ZaaBI -
    ZaaBI_AlonSo wrote:
    i want the user depending the button pressed to show the appropriate image on the third view controller using the image picker.
    If I understand correctly, you want to set the picker source to a custom set of images based on the selection in your second view controller. UIImagePickerController doesn't support this requirement. The picker will only present images from a system source such as the user's photo album or camera roll.
    This SO thread includes links to both the Three20 framework and JPImagePickerController, either of which might solve your problem: [Is there a way to use the UIImagePickerController with your own images?|http://stackoverflow.com/questions/2180214/is-there-a-way-to-use-the-ui imagepickercontroller-with-your-own-images].
    \- Ray

  • [iPhone] View Hierarchy Problems

    I have a program laid out with the navigation controller and a bar button item that leads to the next view... my problem/question is why when I load the program, does it automatically go down a level even farther than i have programmed. It starts on mainView -> Settings -> Settings(the one i never programmed).
    my aim would be to have it just start on the mainView with the button leading to the Settings view.
    Code is as follows:
    - (id)init
    if (self = [super init])
    self.title = @"mainView";
    self.tabBarItem.image = [UIImage imageNamed:@"mainViewTabBar.png"];
    self.navigationItem.rightBarButtonItem =
    [[[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStylePlain
    target:self action:@selector(loadView)] autorelease];
    return self;
    - (void)loadView
    SettingsViewController *settingsView = [[[SettingsViewController alloc] init] autorelease];
    [self.navigationController pushViewController:settingsView animated:YES];
    thanks for any help

    so far, i haven't put any code into SettingsViewController beyond the pre written stuff.. and setting the navBar title. Putting the code in viewDidLoad rather than loadView helped. Instead of going to the view i never programmed, it goes straight to the settingsView. So thankyou for that. When the program starts, i see the transition from the mainView to the settingsView without me touching any buttons... so my guess is that im missing some property for the button or the view im pushing onto the stack? something that inhibits it from automatically drilling down? im not exactly sure.
    #import "SettingsViewController.h"
    @implementation SettingsViewController
    - (id)init
    if (self = [super init])
    self.title = @"Settings";
    return self;
    Implement loadView if you want to create a view hierarchy programmatically
    - (void)loadView {
    If you need to do additional setup after loading the view, override viewDidLoad.
    - (void)viewDidLoad {
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    - (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
    - (void)dealloc {
    [super dealloc];
    @end
    Message was edited by: Bourne89

  • Navigation controller bar on the top of the view

    hi, im trying to figure out how to put navigation controller bar on the top of main view. currently view shows up right after the navigation bar. i want view to take full screen size and navigation controller on the top, so that i can make the navigation controller transparent... any idea? thanks

    That is the Navigation toolbar; be sure it is checked (click it to check or un-check) so that it will display following these instructions:
    *See --> https://support.mozilla.com/en-US/kb/Back%20and%20forward%20or%20other%20toolbar%20items%20are%20missing
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check --> http://www.mozilla.org/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.com/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.com/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.com/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.com/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • My iphone 4S has problem in making and receiving the calls. While making the call , call fails and netwrok disappears. Like wise no voice is heard for incoming calls. This happened after return from the overseas travel.

    My iphone 4S has problem in making and receiving the calls. While making the call , call fails and netwrok disappears. Like wise no voice is heard for incoming calls. This happened after return from the overseas travel.

    Hello SamSax
    Check out the assist page below for troubleshooting call connectivity.
    Calls and connection issues
    http://www.apple.com/support/iphone/assistant/calls/
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • I was using same id on 2 iphones with no problems suddenly everything got mess, how can i set a new id w.out losing my contacts?

    i was using same id on 2 iphones with no problems suddenly everything got mess, how can i set a new id w.out losing my contacts?

    I believe because you migrated from a Nokia to an iPhone you need to register the Bn phone number with your Apple ID so it can be used for iMessage. The Pn number seems to be the only one registered
    Go here > https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/
    Manage your Apple ID and see if that does the trick
    Hope that helps

Maybe you are looking for

  • ITunes 8 Upgrade Results in 5002 unknown Error when trying to update Apps

    iTunes 8 reports that I have apps with updates available. When trying to update them I get this error: We could not complete your iTunes Store Request. An unknown error occurred (5002). There was an error in the Itunes Store. Please try again later.

  • Statspack-doubt about Module

    Hi, I am analyzing a statspack report. All queries starts with a 'Module' clause, like MIS_VFPRIME.exe Module: MIS_VFS.exe Module: VF_Rec_UnAdj.exe FC_TopUp.exe RUU-Utility Module: oracle@acdgcbsodb1b (TNS V1-V3) Module: C:\Documents and Settings\Adm

  • SQLite JDBC system

    Hi All I am trying to create a BI or SAP JDBC system to a SQLite database. Has anyone done this? Thanks Jarrod Williams

  • Importing keyword list from Photoshop CS1 is possible

    Amongst all this gloom on a more positive note I thought people might be interested to know that I have successfully managed to import my long keywords list from Photoshop CS1 into the keywords hud. It is fiddly and I'm sure there must be a more grac

  • Captivate 2 quiz problem

    Hello, I have 20 quiz questions at the end of a captivate 2 project. In edit mode, the quiz question read "Question 1 of 20" etc... When I publish the quiz as a .swf, it starts at "Question 56 of 76" and this gives a weird result. I had other questio