我需要幫助。我已經將xcode更新爲最新版本,並且當我嘗試獲取測試時,舊代碼將引發錯誤「類不是關鍵值scrollView的鍵值編碼」。這個類不是關鍵值編碼兼容的關鍵scrollView
有趣的是,這裏沒有滾動視圖。我有其他看法幾乎精確的代碼,它工作正常。這是代碼。這也沒有筆尖,所以從視圖中取出滾動視圖將不起作用。
#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
和H文件
#import @interface pearGalleryController : UITableViewController { } @end