1
votes

I need help with this. I have updated xcode to the latest and when I try to get test, the old code throws an error "class is not key value coding-compliant for the key scrollView."

Funny thing is that there is no scrollview in this. I have other views almost exact code and it works fine. Here is the code. there is no nib for this either so the taking out the scrollview from the view won't work.


                #import "pearGalleryController.h"
                #import "pearGallery.h"

                @implementation pearGalleryController

                - (void)viewDidLoad {
                    [super viewDidLoad];

                    self.tableView.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:100];
                    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
                    self.navigationItem.title = @"Variety of Pears";

                }



                - (void)didReceiveMemoryWarning {
                    // Releases the view if it doesn't have a superview.
                    [super didReceiveMemoryWarning];

                    // Release any cached data, images, etc that aren't in use.
                }

                - (void)viewDidUnload {

                }


                #pragma mark Table view methods

                - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
                    return 1;
                }


                // Customize the number of rows in the table view.
                - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
                    return 3;
                }

                - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
                {
                    return 122; 
                }

                // Customize the appearance of table view cells.
                - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

                    static NSString *CellIdentifier = @"Cell";

                    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
                    if (cell == nil) {
                        // cell is an object of  the UITableViewCell  this assign an object to a cell   2 memory areas, o need to auto release on the alloc bcause it is an object
                        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
                    }

                    cell.selectionStyle = UITableViewCellSelectionStyleNone;
                    // Set up the cell... 
                    int picIndex = [indexPath row]*3;

                    UIButton* tempView = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 107,123)];

                    [tempView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"pears_%d.png",picIndex]]
                              forState:UIControlStateNormal];

                    tempView.tag = picIndex;
                    [tempView addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:tempView];
                    [tempView release];

                    tempView = [[UIButton alloc]initWithFrame:CGRectMake(106, 0, 107,123)];

                    [tempView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"pears_%d.png",picIndex+1]]
                              forState:UIControlStateNormal];

                    tempView.tag = picIndex+1;
                    [tempView addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:tempView];
                    [tempView release]; 


                    tempView = [[UIButton alloc]initWithFrame:CGRectMake(212, 0, 107,123)];

                    [tempView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"pears_%d.png",picIndex+2]]
                              forState:UIControlStateNormal];

                    tempView.tag = picIndex+2;
                    [tempView addTarget:self action:@selector(buttonClick:)      
                     forControlEvents:UIControlEventTouchUpInside];

                    [cell.contentView addSubview:tempView];
                    [tempView release];     



                    return cell;
                    }


                    -(void)buttonClick:(id)sender



                    {
                    UIButton* btn = (UIButton*)sender;
                    int index = btn.tag;

                    pearGallery *anotherViewController = [[pearGallery alloc] initWithNibName:@"pearGallery" bundle:[NSBundle mainBundle]];

                    anotherViewController.myIndex = index;

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



                    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
                    //UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"video.png"] style:UIBarButtonItemStylePlain target:nil action:nil];
                    self.navigationItem.backBarButtonItem = backButton;
                    [backButton release];

                }


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

                }

                - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
                    return (interfaceOrientation == UIInterfaceOrientationPortrait);
                }

                - (void)dealloc {
                    [super dealloc];
                }


                @end

and the h file


     #import 


    @interface pearGalleryController : UITableViewController {

    }

    @end
2

2 Answers

1
votes

probably a dangling reference in your xib file, check to make sure references are cleared.

0
votes

Usually this error occurs when you have an object , in your case it is the 'scrollView' which is attached via the interface builder to the scrollView item in storyboard/xib.

Check your links in interface builder ( furthest tab to the right ) and that you don't have a duplicate link to another IBOutlet.

I find this only occurs to me when I link an object up then 'mistype' my link , I go to change it but don't remove the old link from interface builder ie SCrollview and scroLLview2

Go to your interface builder ( connection tab ) and check you don't have duplicate links. Remove all links to your 'scrollview' and 're link' to your .h file then try again

you may have typed scrollView then changed it to scrollview and not realised..good luck