Iphone 无法从tableView中选择单元格
嗨,朋友们,这是我面临的一个奇怪的问题,我在一个分组表视图中使用多个Iphone 无法从tableView中选择单元格,iphone,objective-c,ios,ipad,uitableview,Iphone,Objective C,Ios,Ipad,Uitableview,嗨,朋友们,这是我面临的一个奇怪的问题,我在一个分组表视图中使用多个UItableCustomCells,并带有分区 我只能选择第一节的行,然后当我单击另一节的行时,它的选择方法不起作用,我无法理解错误在哪里,我的cellforrowatinexpath代码如下:- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSStr
UItableCustomCells
,并带有分区
我只能选择第一节的行,然后当我单击另一节的行时,它的选择方法不起作用,我无法理解错误在哪里,我的cellforrowatinexpath
代码如下:-
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier =[NSString stringWithFormat:@"%d",indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//if (cell == nil) {
if(indexPath.section==0)
{
if(indexPath.row==0)
{
[[NSBundle mainBundle]loadNibNamed:@"CustomCell1" owner:self options:nil];
cell = self.Cell1;
self.Cell1 = nil;
txtincidentName = (UITextField*)[cell.contentView viewWithTag:1];
}
else if(indexPath.row==1)
{
[[NSBundle mainBundle]loadNibNamed:@"CustomCell2" owner:self options:nil];
cell = self.Cell2;
self.Cell2 = nil;
lblDatefirst = (UILabel*)[cell.contentView viewWithTag:2];
btnCalfirst = (UIButton*)[cell.contentView viewWithTag:3];
lblTimeFirst = (UILabel*)[cell.contentView viewWithTag:4];
}
else if(indexPath.row==2)
{
[[NSBundle mainBundle]loadNibNamed:@"CustomCell2" owner:self options:nil];
cell = self.Cell2;
self.Cell2 = nil;
lblDatefirst = (UILabel*)[cell.contentView viewWithTag:2];
btnCalfirst = (UIButton*)[cell.contentView viewWithTag:3];
lblTimeFirst = (UILabel*)[cell.contentView viewWithTag:4];
lblInciTime =(UILabel*)[cell.contentView viewWithTag:9];
lblInciTime.text=@"Date/Time";
}
}
else if(indexPath.section==1)
{
if(indexPath.row==0)
{
[[NSBundle mainBundle]loadNibNamed:@"CustomCell3" owner:self options:nil];
cell = self.Cell3;
self.Cell3 = nil;
btndropDown1 = (UIButton*)[cell.contentView viewWithTag:5];
btndropDown2 = (UIButton*)[cell.contentView viewWithTag:6];
btndropDown3 = (UIButton*)[cell.contentView viewWithTag:7];
}
else if(indexPath.row==1)
{
[[NSBundle mainBundle]loadNibNamed:@"CustomCell4" owner:self options:nil];
cell = self.Cell4;
self.Cell4 = nil;
txtViewofdetails = (UITextView*)[cell.contentView viewWithTag:7];
}
}
return cell;
}
模拟器图像
请帮助和指导谢谢。不要像这样从笔尖加载单元格。而是在NIB中使用重用标识符注册单元。这将导致排队系统根据标识符选择正确的单元原型
最有可能的是,您当前的方法弄乱了表视图的触摸处理。请尝试这种类型的概念和代码流
NSString *CellIdentifier =[NSString stringWithFormat:@"%d%d",indexPath.section,indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell1" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell1 *) currentObject;
break;
}
}
}
你能从DidselectRowAtindexPath发布一些代码吗?在didSelectRow中设置断点..你能访问这个/。?在SELECTION处没有蓝线,但我有4个不同的自定义单元格(你能如上编辑我的代码吗?。?嘿@NitinGohel只需在你的if条件中使用概念和设置条件,如果它为零,则创建它,并发布didselect方法dude的代码..bhai是否选择了ma kai代码nathi Response j nathi malto选择行否bhai@NitinGohelbhai thay 6 su main??表示行选择nathi thati??是bhai sav nani误认为hati,但胡比吉·贾贾贾耶·查迪·吉奥错认为sholv导航错误凯塔·比亚·萨拉姆大街手机用户界面启用检查卡雷卢·纳图:(