これについて助けが必要です。xcode を最新のものに更新しましたが、テストを取得しようとすると、古いコードで「クラスはキー scrollView のキー値コーディングに準拠していません」というエラーがスローされます。
面白いことに、これにはスクロールビューがありません。他のビューはほぼ正確なコードで、正常に動作します。これがコードです。これにもペン先がないため、ビューからスクロールビューを取り出すことはできません。
#import "pearGalleryController.h"
#import "pearGallery.h"
@実装 pearGalleryController
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.backgroundColor = [UIColor colorWithRed:0.0 緑:0.0 青:0.0 アルファ:100];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.navigationItem.title = @"梨の品種";
}
- (void)didReceiveMemoryWarning {
// スーパービューがない場合はビューを解放します。
[super didReceiveMemoryWarning];
// 使用されていないキャッシュ データ、画像などを解放します。
}
- (void)viewDidUnload {
}
#pragma mark テーブル ビュー メソッド
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
1 を返します。
}
// テーブル ビューの行数をカスタマイズします。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3 を返します。
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
122 を返します。
}
// テーブル ビュー セルの外観をカスタマイズします。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"セル";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (セル == nil) {
// セルは UITableViewCell のオブジェクトです これはセルにオブジェクトを割り当てます
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// セルを設定...
int picIndex = [indexPath 行]*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 リリース];
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 リリース];
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 リリース];
セルを返します。
}
-(void)buttonClick:(id)送信者
{
UIButton* btn = (UIButton*) 送信者;
int インデックス = btn.tag;
pearGallery *anotherViewController = [[pearGallery alloc] initWithNibName:@"pearGallery" bundle:[NSBundle mainBundle]];
anotherViewController.myIndex = インデックス;
[self.navigationController pushViewController:anotherViewController アニメーション:YES];
[別のViewControllerリリース];
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;
[戻るボタンを離す];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (無効)dealloc {
[スーパーdealloc];
}
@終わり
そしてhファイル
#輸入
@interface pearGalleryController : UITableViewController {
}
@終わり