我正在使用UITableView
进行Json
解析。
在
中 -(void) connectionDidFinishLoading :(NSURLConnection *) connection{
self.resultTable.delegate = self;
self.resultTable.dataSource = self; }
我正在解析数据并设置UITableView's
delegate
和datasource
个自我。
当我编译该程序时,我使用jSON
解析的数据正确无误地运行。
主要问题是:当我尝试点击行表时,调试器永远不会来
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
我尝试过很多东西(包括segue等......)但是我不能用手指轻敲任何单元格的行。这真的让我感觉像是在点击文本字段......
有人知道这个问题吗?
最诚挚的问候......
- 编辑 -
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
_userSettings = [NSUserDefaults standardUserDefaults];
static NSString *CellIdentifier =@"CellID";
ResultNearbyList *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell.profilePictureIndicator startAnimating];
if (cell == nil) {
cell = [[ResultNearbyList alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.userProfilePicture.profileID = [userFBIDArray objectAtIndex:indexPath.row];
self.userDOBStr = [userDOB objectAtIndex:indexPath.row];
self.userGenderStr = [userGender objectAtIndex:indexPath.row];
[cell.profilePictureIndicator stopAnimating];
[_listNearbyView stopAnimating];
cell.userNickName.text = [userNickNameArray objectAtIndex:indexPath.row];
NSString *fullName = [userFullNameArray objectAtIndex:indexPath.row];
NSString* fullNameUTF8 = [NSString stringWithUTF8String:[fullName cStringUsingEncoding:NSUTF8StringEncoding]];
//NSString *fullNameUTF8 = [NSString stringWithCString:[fullName cStringUsingEncoding:NSISOLatin1StringEncoding] encoding:NSUTF8StringEncoding];
cell.userFullName.text = fullNameUTF8;
NSString *userCityCountry = [userCountryArray objectAtIndex:indexPath.row];
userCityCountry = [userCityCountry stringByAppendingString:@"/"];
userCityCountry = [userCityCountry stringByAppendingString:[userCityArray objectAtIndex:indexPath.row]];
cell.userCityCountry.text = userCityCountry;
NSString *userDestination = [userDistanceArray objectAtIndex:indexPath.row];
NSRange range = [userDestination rangeOfString:@"."];
NSString *substring = (range.location != NSNotFound) ? [userDestination substringToIndex:range.location] : nil;
substring = [substring stringByAppendingString:@" km"];
if([substring intValue] == 0)
{
substring = (range.location != NSNotFound) ? [userDestination substringFromIndex:range.location] : nil;
substring = [substring substringWithRange:NSMakeRange(0, 4)];
substring = [substring stringByAppendingString:@" m"];
}
cell.userDistance.text = substring;
return cell;
}
屏幕截图:1
答案 0 :(得分:0)
转到故事板,选择UITable并检查选择是否设置为“单选”。另请注意复选标记“显示触摸选择”
答案 1 :(得分:0)
我发现了自己的错误。我缺少的部分是,我只是将Objective-c类文件添加为UIViewController,用于创建Cell原型视图。比我改变了UIViewController - > UITableViewCell中。但是手动更改为类类型,没有添加以下实例:
- (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
}
当我将这些实例设置为我的UItableViewCell类实现文件时,问题已修复:)
感谢您的帮助......