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