ナビゲーションテンプレートを使用してマルチビューアプリケーションを作成しようとしています。私は最初のビューの下部に、他のビュー(画像ビュー、ラベルなど)を上にしてテーブルを必要とします。RootControllerを使用したマルチビューTableView
元々、RootViewController.xibを変更してtableviewのサイズを変更し、イメージビューを追加しましたが、フルサイズのテーブルを除いて何も表示されませんでした。
RootViewController.xibを変更してUIViewを追加し、そのビューにUITableViewとUIImageViewを追加しました。私はtableViewのIBOutletを追加しました。私のRootViewController.xibでは、File 'S Owner(RootViewController)にはビューとテーブルビューへのアウトレット接続があります。 UITableViewを右クリックすると、File's Ownerへの参照アウトレットが表示されます。 UIViewを右クリックすると、File's Ownerへの参照アウトレットが表示されます。 (私はコードで変更しないので、UIImageViewのコンセントはありません;必要がありますか?)私はアプリを起動したときに
はしかし、それはメッセージでクラッシュ:
'NSInternalInconsistencyException',
reason: '-[UITableViewController loadView] loaded the "RootViewController" nib but didn't get a UITableView.'
わからないが、なぜ、どのように解決します。どんな助力も非常に深く感謝しています。
(のUITableViewCell *)のtableView:(のUITableView *)のtableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
静的NSStringの* QuizIdentifier = @ "QuizIdentifier" ここ
はcellForRowAtIndexPath法であります;
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:QuizIdentifier];
IF(セル== NIL){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:QuizIdentifier] autorelease];
}
UIImage * _image = [UIImage imageNamed:@ "icon.pngの"]。
cell.imageView.image = _image;
NSInteger row = [indexPath row];
cell.textLabel.text = [_categories objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
リターンセル; }
OK、ここに行く:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *QuizIdentifier = @"QuizIdentifier";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:QuizIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:QuizIdentifier]
autorelease];
}
// Configure the cell.
UIImage *_image = [UIImage imageNamed:@"icon"];
cell.imageView.image = _image;
NSInteger row = [indexPath row];
cell.textLabel.text = [_categories objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
[OK]を、私はRootViewController.hでのUIViewControllerにのUITableViewControllerを変えました。空のテーブルと同じように画像ビューが表示されるようになりました。ナビゲーションベースのアプリではなく、通常のビューベースのアプリのようです。この場合、ナビゲーションテンプレートを使用する理由はありますか? – Namhcir
それでは、まだ問題はありますか、それとも今は動作していますか? – edc1591
OK、これまでのところ動作します。ただし、セルのプロパティを表示する際に問題が発生しています。 [array objectAtIndex:row]メッセージからcell.textLabel.textをロードすると正しく表示されます。しかし、アクセサリタイプや画像を表示しようとすると、次のように表示されます:cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;私はこれらのプロパティを表示することはできません。すべてのアイデアを大いに感謝します。 – Namhcir