Mar*_*ist 5 iphone objective-c uitableview ios
我有一个iOS应用程序,其中包含几个UITableViews,所有这些都按预期工作.我升级应用程序以处理iOS8
从那时起,我遇到了一个问题,即将自定义单元格加载到表格视图中,谁的笔尖在ib中选中了"使用自动布局"的框.然后我在我的自定义单元格中取消选中所有这些,从那时起,我所有UITableViews的单元格不仅不调用didSelectRowAtIndex路径方法,而且在触摸时不会突出显示.
我通过添加检查所有单元格是否处于活动状态
if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");}
Run Code Online (Sandbox Code Playgroud)
所有已加载的单元格写入"已启用"到日志中
我通过故事板中的ib设置委托和数据源,所有这些都在我更改"使用自动布局"并升级到iOS 8上运行之前有效.
我错过了什么?
这是我创建单元格的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TableCellWithNumberCellIdentifier";
if( events.count>indexPath.row &&[[[events objectAtIndex:indexPath.row] objectForKey:@"tag"] integerValue] == -1)
{
EventsMonthSeparator *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell.translatesAutoresizingMaskIntoConstraints=NO;
cell = (EventsMonthSeparator *)[EventsMonthSeparator cellFromNibNamed:@"EventsMonthSeparator"];
cell.date.text=[[events objectAtIndex:indexPath.row] objectForKey:@"date"];
[Functions setFontFamily:@"Neutra Display" forView:cell andSubView:YES];
if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");}
}
return cell;
}else
{
eventsRow *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell.translatesAutoresizingMaskIntoConstraints=NO;
cell = (eventsRow *)[eventsRow cellFromNibNamed:@"eventsRow"];
cell.description.text=[[events objectAtIndex:indexPath.row] objectForKey:@"name"];
cell.timedate.text=[[events objectAtIndex:indexPath.row]objectForKey:@"date"];
cell.image.image=[UIImage imageNamed:@"tiledrinks"];
cell.status.text=[Functions statusForIndex:[[[events objectAtIndex:indexPath.row] objectForKey:@"booked"] intValue]];
[Functions setFontFamily:@"Neutra Display" forView:cell andSubView:YES];
cell.tag=1;
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
if(cell.userInteractionEnabled){NSLog(@"is enabled");}else{NSLog(@"is not enabled");}
}
return cell;
}
}
Run Code Online (Sandbox Code Playgroud)
Sha*_*hal 16
请不要检查Auto-Layout
是OFF
(非选择对勾标记),您的自定义单元格xib
也.
在您TableView
选中此默认设置时,如下图所示
我有同样的问题一次,我在那里给NO Selection
在selection
TableView中的财产attribute inspector
.
如果你已经做了同样的事情,那就去吧Single selection
.
希望对你有帮助 !
归档时间: |
|
查看次数: |
13532 次 |
最近记录: |