【发布时间】:2012-12-10 23:11:15
【问题描述】:
我有两个表视图。
一个是简单的,另一个是定制的。我通过 JSON 获取值。我一次发出一个 JSON 请求,但是当我同时调用简单表和自定义表的 JSON 请求时,它会在自定义表上显示数据,但之后突然加载简单表,但它隐藏了第一个自定义表的数据表。
有人知道为什么会这样吗?
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
if (tableView==self.table) {
return 1;
}
else if(tableView==self.clearificationTable){
return 1;
}
return 0;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (tableView==self.table) {
return [reminderArrayList count];
}
else if(tableView==self.clearificationTable) {
return [taskListArray count];
}
return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (tableView==self.table) {
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"MyCell"];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];
}
cell.textLabel.text=[reminderArrayList objectAtIndex:indexPath.row];
newCell=cell;
}
else if (tableView==self.clearificationTable) {
static NSString *CellIdentifier=@"Cell";
StaffDahsBoardCustom *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
[[NSBundle mainBundle]loadNibNamed:@"StaffDahsBoardCustom" owner:self options:nil];
}
cell=custom;
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.taskListlbl.text=[taskListArray objectAtIndex:indexPath.row];
cell.tasktypelbl.text=[tasktypeArray objectAtIndex:indexPath.row];
cell.completelbl.text=[NSString stringWithFormat:@"%@",[completeArray objectAtIndex:indexPath.row]];
cell.incompletelbl.text=[NSString stringWithFormat:@"%@",[incompleteArray objectAtIndex:indexPath.row]];
cell.nalbl.text=[NSString stringWithFormat:@"%@",[NaArray objectAtIndex:indexPath.row]];
cell.returnlbl.text=[ReturneDateArray objectAtIndex:indexPath.row];
newCell=cell;
}
return newCell;
}
【问题讨论】:
-
给每个不同的标签。
[tableView setTag:] -
为什么-1我的答案是对的?
-
养成正确格式化代码的习惯...我现在累了....ufff
-
gopal ji..answer 接受 karo
标签: iphone objective-c ipad cocoa-touch ios-simulator