【发布时间】:2015-06-20 21:33:35
【问题描述】:
我无法找到我放置在自定义单元格“GameTableCell.H”中的两个图像和文本框...不知道我在这里做错了什么。
GameTableCell.H:
//
#import <UIKit/UIKit.h>
@interface GameTableCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *GameTime;
@property (strong, nonatomic) IBOutlet UIImageView* AwayImage;
@property (strong, nonatomic) IBOutlet UIImageView* HomeImage;
@end
GameTableCell.m:
//
#import "GameTableCell.h"
@implementation GameTableCell
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
我已经连接的项目很好...
调用GameTableCell....是主页
主页.H:
#import <UIKit/UIKit.h>
@interface HomePage : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *PendingChal;
@property (strong, nonatomic) IBOutlet UITableView *ActiveChal;
@property (nonatomic, strong)NSArray *HomeImages;
@property (nonatomic, strong)NSArray *AwayImages;
@property (nonatomic, strong)NSArray *SportGameInfo;
@end
主页.m:
//
#import "HomePage.h"
#import "PickSport.h"
#import "GameTableCell.h"
@interface HomePage ()
@end
@implementation HomePage
@synthesize ActiveChal,PendingChal;
-(IBAction)makeChallenge:(id)sender{
PickSport *second = [[PickSport alloc] initWithNibName:@"PickSport" bundle:nil];
[self presentViewController:second animated:YES completion:nil];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Arrays for filling table cells
_HomeImages=@[@"ic_bengals_nfl",@"ic_bengals_nfl",@"ic_bengals_nfl",@"ic_bengals_nfl", ];
_AwayImages=@[@"ic_bears_nfl",@"ic_bears_nfl",@"ic_bears_nfl",@"ic_bears_nfl", ];
_SportGameInfo=@[@"7:00pm",@"8:00pm",@"9:00pm",@"10:00pm",];
[self.PendingChal registerClass: [UITableViewCell class]forCellReuseIdentifier:@"GameTableCell"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//Set up the table props
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
//number of rows in the table
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// rows eqiv to length of array SportGameinfo
return _SportGameInfo.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier=@"GameTableCell";
GameTableCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if(tableView == PendingChal){
if (!cell) {
NSLog(@"cell was nil");
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
int row =[indexPath row];
cell.HomeImage.image=[UIImage imageNamed:_HomeImages[row]];
cell.AwayImage.image=[UIImage imageNamed:_AwayImages[row]];
cell.GameTime.text=_SportGameInfo[row];
}
if(tableView == ActiveChal){
int row =[indexPath row];
cell.GameTime.text=_SportGameInfo[row];
cell.HomeImage.image=[UIImage imageNamed:_HomeImages[row]];
cell.AwayImage.image=[UIImage imageNamed:_AwayImages[row]];
}
return cell;
}
具体错误如下: 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UITableViewCell HomeImage]:无法识别的选择器发送到实例 0x79ee11a0” *** 首先抛出调用栈:
任何帮助将不胜感激......我觉得我做的事情有点不对(我希望)。
【问题讨论】:
-
请添加更多标签,例如编程语言和与您的查询相关的其他标签
-
@Anand 已添加,谢谢!
-
你使用 Images.xcassets 添加图像???还要添加异常断点
-
有没有达到
"cell was nil"部分?我建议你不要分配UITableViewCell,而是分配GameTableCell -
是的,我正在从 xcassettes 中提取它们。最终我会从一个我试图让这个“虚拟”表首先在本地运行的 url 中提取,然后再进入互联网的深处。
标签: ios objective-c uitableview unrecognized-selector