1

I'm noob in iPhone programming.

I want to create navigation-based application with several nested views, when first and second are UITableView-type, and the third is simple UIView with my own interface, which I built in Interface builder.

When I run the App, touch the row on the first table-view I transfer to the second, and when I touch the row on the second, I transfer to the third, but on the third View I don't see my interface, which I built in Interface Builder, just blank screen.

This is part of my code, where I try to call my third view:

    if(self.reportView == nil){    
        ReportTypeViewController *viewController = 
        [[ReportTypeViewController alloc] initWithNibName:@"ReportTypeViewController" 
                                            bundle:[NSBundle mainBundle]];
        self.reportView = viewController;
        [viewController release];        
    }


    [self.navigationController pushViewController:self.reportView  animated:YES];
    self.reportView.title = @"Reports"; 

That's OK, guys. I've just didn't add text to my button, that lies on my view, that's why it was blank.

7
  • Is ReportTypeViewController a subclass of your 2nd UITableViewController (the one that calls it)? Commented Aug 10, 2011 at 21:37
  • It's inherited from UIViewController. Commented Aug 10, 2011 at 21:47
  • I created ReportTypeViewController by choosing UIViewController subclass. How to make sure, that ReportTypeViewController is a subclass of my 2nd UITableViewController? Commented Aug 10, 2011 at 21:53
  • After reading some more of your comments, I don't think this is your problem but you can try it and see. To make ReportTypeViewController a subclass of your 2nd UITableViewController, open the header (.h) file for ReportType view controller and replace "ReportTypeViewController : UIViewController" with "ReportTypeViewController : NameOfSecondTableViewController" again I'm pretty sure this isn't your problem... as far as I know a UIViewController should work. Commented Aug 10, 2011 at 22:01
  • An error shows, when I change the class I inherted from. Commented Aug 10, 2011 at 22:08

3 Answers 3

2

You don't need [NSBundle mainBundle];

it should look like this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    ReportViewController *vc = [[ReportViewController alloc] initWithNibName:ReportViewController bundle:nil];
    vc.title = @"Reports";
    [self.navigationController pushViewController:vc animated:YES];
    [vc release];
}

If you just create the view on demand with the selection it's much easier.

Sign up to request clarification or add additional context in comments.

1 Comment

I made exactly what you wrote, but there's still the problem.
2

In IB, make sure you remembered to set the Class of File's Owner to ReportTypeViewController, and make sure that the view outlet of File's Owner is connected to your view.

1 Comment

I checked your advices in IB, it's OK. But the app still works not as expected.
0

Does ReportTypeViewController really inherit from UIViewController, or is it a UIView, as you say you built in IB?

navigationController pushViewContoller:animated: needs a UIViewController not a UIView. In IB, you can add a UIViewController and move your UIView onto it, or create it programmatically.

1 Comment

Yes, it's inherited from UIViewController.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.