Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3941110
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:30:05+00:00 2026-05-20T00:30:05+00:00

i have a main table view. and a DetailView. when cell is clicked, DetailView

  • 0

i have a main table view. and a DetailView. when cell is clicked, DetailView of that cell comes which shows details of that cell. DetailView has two buttons next and previous. I wanna know how to disable a detail view button from RootViewcontroller.m. code looks like this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    DetailViewController *nextController = [[DetailViewController alloc] init];
    int storyIndex = [indexPath indexAtPosition:[indexPath length] -1];
    nextController = [nextController initWithObjectAtIndex:storyIndex inArray:stories];

    NSString *storyTitle = [[stories objectAtIndex:storyIndex] objectForKey:@"title"];
    nextController.title = @"Details";

    UIBarButtonItem *tempButtonItem = [[[UIBarButtonItem alloc] init] autorelease];
    tempButtonItem.title = @"Back";

    self.navigationItem.backBarButtonItem = tempButtonItem ;

    nextController.sTitle = storyTitle;
    [self.navigationController pushViewController:nextController animated:YES];

    [nextController release];

}

i have already tried nextController.next.enabled=NO and [nextController.next setEnabled:NO] after this line:
[self.navigationController pushViewController:nextController animated:YES];

where next is the UIBarButtonItem name which is in DetailViewController.
can anybody tell me how to disable that button.
thanx in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:30:06+00:00Added an answer on May 20, 2026 at 12:30 am

    Viewcontrollers and views are not loaded at the same time. What this means is that when you instantiate an object of DetailViewController in your case, the views are not drawn(and if you are using Nib’s) loaded, this is part of the lazy loading concept.

    So the first time you send the message setEnabled = NO, the object will be nil(sending messages to objects that are nil is allowed in Objective C).

    Example:

    [nextController setEnabled:NO] is equal to [nil setEnabled:NO] and this is surely not what you want.

    The next time, unless a memory warning and the views are unloaded, the views will be in memory and the reference to the button will no longer be nil so the second time you invoke it, it will work.

    And add the code line above the pushViewController:animate

    If you want to initialize the button to be disable you may put this code in the viewDidLoad/viewWillAppear depending on the context of your application.

    This is only one possible solution.


    Edited answer to request in comment:

    In your initializer method in the DetailviewController add this:

    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(backToRoot)] autorelease];
    
    - (void)backToRoot {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    

    and also add the method-signature to your headerfile.

    Reference to the UINavigationController: http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
I have a button in a table view cell which, when pressed brings up
I have a main table view and a detail view. when i click cell
I have a main view controller which is a tableview, after selecting a cell
I have an iPhone app which has a Table View-based data input screen with
I have a main table that I must get data from. I have a
i have a table called category in which i have main category ids and
I have a tableview inside a popover in my main view which is a
i have this MainViewController, which is a controller for my table view. Whenever I
I have a table view project with multiple controllers and another one that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.