Я делаю упражнение около tableView
и tableViewCell
. И у меня возникают проблемы с пользовательскими ячейками просмотра.No Visible View in Custom Table View Cell
Я создал свой собственный tableViewCell
с .xib файлом, который называется newCellView.xib
. Мне нужны файлы .h и .m, и я выбираю суперкласс как UITableViewCell
.
На мой взгляд, контроллер называется TableViewController
Я создавал таблицу с ячейками по умолчанию, как это.
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.text = [showNames objectAtIndex:[indexPath row]];
cell.imageView.image = [UIImage imageNamed:[iconArray objectAtIndex:[indexPath row]]];
return cell;
}
Как только я создал свой собственный пользовательский вид. Я импортировал newViewCell.h
в мой viewController
, и я обновил код следующим образом.
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *newCellViewString = @"newCellView";
newCellView *cell = [tableView dequeueReusableCellWithIdentifier:newCellViewString];
//newCellView *cell = [[newCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:newCellView];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"newCellView" owner:self options:nil];
cell = (newCellView *)[nib objectAtIndex:0];
}
Но когда я запускаю приложение, я вижу пустую страницу, например, у меня нет соответствующего вида. Возможно, я забыл добавить некоторые добавления. Я даже не вижу пустые ячейки для просмотра. Только белая пустая страница. Любая помощь будет большой. Благодарю.
EDIT для других файлов
Вот мой .h и .m файлов.
#import <UIKit/UIKit.h>
@interface newCellView : UITableViewCell <UITableViewDelegate>
@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *iconImageView;
@property (retain, nonatomic) IBOutlet UIButton *extendButton;
@end
.m файл
#import "newCellView.h"
@implementation newCellView
@synthesize nameLabel;
@synthesize extendButton;
@synthesize iconImageView;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)dealloc {
[extendButton release];
[nameLabel release];
[iconImageView release];
[super dealloc];
}
@end
Кажется, что ваш табличный обзор находится за некоторым источником данных проверки данных, а также – amar
ли вы создаете объект для просмотра лабиринтов и изображений и связали его с newViewCell в вашем newViewCell.xib? – KDeogharkar
, так что я должен сделать, чтобы это увидеть? Настройка этого представления как root? – erenkabakci