butchcowboy
butchcowboy

Reputation: 565

iPhone SDK: pushViewController crashing

I am having problems with getting a detail view to load using pushViewController. At first, I thought pushViewController was not working. BUT, then I tried using a different view controller and it worked. I can tell from tracing that the problem view controller is never loaded at all. In other words, I tried to eliminate the possibility that there was some error in the view controller by NSLoging in that object and I never see anything.

Does anyone have any ideas?

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

/*  
    NSLog(@"hsitkjsdfkljlkd");

    if (childController == nil)
        childController = [[salesViewController alloc] initWithNibName:@"salesView" bundle:nil];

    //NSUInteger row = [indexPath row];

    [self.navigationController pushViewController:childController
                                         animated:YES];

 */

/*  

    //modal = blocking
    salesViewController *otherVC = [[salesViewController alloc] initWithNibName:@"salesView" bundle:nil];

    //must set sale type
    otherVC.strSaleType = @"Voice";

    [self presentModalViewController: otherVC animated:YES]; 

    //No close. By design, it is up to the otherVC to close itself  

    */

    //tipCalcViewController *detailViewController = [[tipCalcViewController alloc] initWithNibName:@"tipCalcView" bundle:nil];
    salesViewController *detailViewController = [[salesViewController alloc] initWithNibName:@"salesView" bundle:nil];
    // ...
    // Pass the selected object to the new view controller.

    [self.navigationController pushViewController:detailViewController animated:YES];
    [detailViewController release]; 


}

Upvotes: 0

Views: 2711

Answers (4)

iAnkit
iAnkit

Reputation: 1960

When you're pushing from ViewController1 to ViewController2 then the code will be used like this so try this code,

ViewController2 *vw2=[[ViewController2 alloc]initWithNibName:@"ViewController2" bundle:nil];
[self.navigationController pushViewController:vw2 animated:YES];

The Above code may be written on Click event of button or on didSelect delegate of UITableView

Upvotes: 0

seb
seb

Reputation: 2385

In my case I had several IBOutlets that I removed from the Header file and forgot to remove the connection to these non-existing outlets in Interface Builder. So removing the obsolete outlets fixed the problem in my case.

Upvotes: 0

Rakesh Bhatt
Rakesh Bhatt

Reputation: 4606

Just Check the

- (void)viewWillAppear:(BOOL)animated
{


}

of the salesViewController.

you are doing something wrong in this..

put the debugging point in the viewWillAppear and run it. you can get the error line..

Upvotes: 3

Ajay Sharma
Ajay Sharma

Reputation: 4517

just try it......Surely it will work for u...

salesViewController *detailViewController = [[salesViewController alloc] initWithNibName:@"salesViewController" bundle:nil];

// Pass the selected object to the new view controller.

[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release]; 

Also make sure you are giving the IBOutlet connection to UIView.

Upvotes: 0

Related Questions