0

I need to create a tableview within the detail side of a splitview. I have learned how to create a tableview programmatically and have created it in a class called MyTableView. My problem is that the point at which I want to actually create the tableview, I am getting an error. The code from the DetailViewController shown below is being called, but the tableview (called nextView) isn't being populated. Please let me know if you see a silly mistake or can recommend any tutorials that would be helpful.

- (void)setDetailItem:(id)newDetailItem {
    if (detailItem != newDetailItem) {
        [detailItem release];
    detailItem = [newDetailItem retain];
    // Update the view
NSLog(detailItem);
NSString * imageName = [NSString stringWithFormat:@"%@.png",detailItem];
    [self.imageView1 setImage:[UIImage imageNamed:imageName]];  
    [self configureView];
}

if (self.popoverController != nil) {
    [self.popoverController dismissPopoverAnimated:YES];
}        
}


- (void)configureView {
NSLog(@"creating tableview");
if(nextView == nil)
    nextView = [[MyTableView alloc] init];  
self.view = nextView;
}

The error reads: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyTableView setFrame:]: unrecognized selector sent to instance 0x4b32e40'

Haven't found an answer for the splitview yet, but two tables within scroll views are working all right. Here's the blog that got me started. http://www.iphonedevsdk.com/forum/iphone-sdk-development/2423-multiple-table-views-single-screen-nothing-showing-up.html

Rebecca
  • 55
  • 5
  • If the error is `[MyTableView setFrame:]` and it sees an unrecognized selector maybe you meant `[nextView setFrame]` rather than what you have. Where abouts does the error occur? On the `self.view = nextView` line? – tacos_tacos_tacos Aug 14 '11 at 04:25
  • Thank you. I tried both of those. No luck. I have since tried to use a tableviewcontroller too. Thanks for trying. I'll post more specific errors as soon as I can. – Rebecca Aug 14 '11 at 18:17

1 Answers1

0

Is the class MyTableView in reality a table view controller. In this case the table view controller has no property frame. You should then to something like

[[MyTableView view] setFrame: newFrame];

And: You should change the name of MyTableView to MyTableViewController.

dasdom
  • 13,975
  • 2
  • 47
  • 58
  • When i tried to implement that line, it said newFrame wasn't initialized. is newFrame something I should have created or is it part of the navigation template? I am using splitview, so it doesn't exist for me. Also, should I change just the name of MyTableView or should I create a class that is really a UITableViewController instead of a UITableView as I did? Thanks a bunch for the help. – Rebecca Aug 14 '11 at 18:15