0

我有 3 个段的段控制,最初它在 tableview 中显示数据。当我点击其他部分时,它给了我这个例外。真的很难弄清楚是什么问题。如果需要,我可以发布代码。

libobjc.A.dylib`objc_msgSend:
0x192308c:  movl   8(%esp), %ecx
0x1923090:  movl   4(%esp), %eax
0x1923094:  testl  %eax, %eax
0x1923096:  je     0x19230e8                 ; objc_msgSend + 92
0x1923098:  movl   (%eax), %edx
0x192309a:  pushl  %edi
0x192309b:  movl   8(%edx), %edi     <-------HERE 
0x192309e:  pushl  %esi
0x192309f:  movl   (%edi), %esi
0x19230a1:  movl   %ecx, %edx
0x19230a3:  shrl   $2, %edx
0x19230a6:  andl   %esi, %edx
0x19230a8:  movl   8(%edi,%edx,4), %eax
0x19230ac:  testl  %eax, %eax
0x19230ae:  je     0x19230b9                 ; objc_msgSend + 45
0x19230b0:  cmpl   (%eax), %ecx
0x19230b2:  je     0x19230d0                 ; objc_msgSend + 68
0x19230b4:  addl   $1, %edx
0x19230b7:  jmp    0x19230a6                 ; objc_msgSend + 26
0x19230b9:  popl   %esi
0x19230ba:  popl   %edi
0x19230bb:  movl   4(%esp), %edx
0x19230bf:  movl   (%edx), %eax

我的段切换方法。它的第 1 段是不工作的。

- (IBAction)segmentSwitch:(id)sender
{
  NSInteger selectedSegment = [sender selectedSegmentIndex];

  if(selectedSegment == 0)
  {

    [tableview1 reloadData];
  }
  if(selectedSegment == 1)
  {
    NSLog(@"Above reloaddata");
    [tableview1 reloadData];
    NSLog(@"Below reloaddata");
  }
  if(selectedSegment == 2)
  {
    UIAlertView *save = [[[UIAlertView alloc]
                          initWithTitle:@"Alert!"
                          message:@"No Data Found"
                          delegate:self
                          cancelButtonTitle:@"Ok"
                          otherButtonTitles: nil] autorelease];
    [save show];
 }
}

表视图代表

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(tableView == tableview1){
    NSInteger selectedSegment = segmentControl.selectedSegmentIndex;
    if(selectedSegment == 0)
        return arraycontacts.count;
    if(selectedSegment == 1)
    {
         return phPatch.count; 
    }


 }
 else
    return 0;
 }

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath    *)indexPath
{
  UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];

if(cell==nil)
{
    cell= [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]autorelease];

}

if(tableView == tableview1){

    NSInteger selectedSegment = segmentControl.selectedSegmentIndex;

    if(selectedSegment == 0){
        NSLog(@"In segment 0");

        cell.textLabel.text=[arraycontacts objectAtIndex:indexPath.row];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        UILabel *typeLabel = [[[UILabel alloc]init]autorelease];
        typeLabel.backgroundColor = [UIColor clearColor];
        typeLabel.text = [arraypatch objectAtIndex:indexPath.row];
        typeLabel.textAlignment = UITextAlignmentCenter;
        typeLabel.frame = CGRectMake(300,2.0f,150,50);
        [cell addSubview:typeLabel];


        UILabel *typeLabel1 = [[[UILabel alloc]init]autorelease];
        typeLabel1.backgroundColor = [UIColor clearColor];
        typeLabel1.text = [arrayclass objectAtIndex:indexPath.row];
        typeLabel1.textAlignment = UITextAlignmentCenter;
        typeLabel1.frame = CGRectMake(400,2.0f,150,50);
        [cell addSubview:typeLabel1];


        UILabel *typeLabel2 = [[[UILabel alloc]init]autorelease];
        typeLabel2.backgroundColor = [UIColor clearColor];
        typeLabel2.text = [arrayspeciality objectAtIndex:indexPath.row];
        typeLabel2.textAlignment = UITextAlignmentCenter;
        typeLabel2.frame = CGRectMake(500,2.0f,250,50);
        [cell addSubview:typeLabel2];


        UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(770,2.0f,250,50)] autorelease];
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        btn.frame = CGRectMake(10,0, 150, 40);
        [btn setTitle:@"Precall" forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(precallClicked:) forControlEvents:UIControlEventTouchUpInside];
        [headerView addSubview:btn];
        [cell addSubview:headerView];

        cell.tag = indexPath.row;

    }

   if(selectedSegment == 1){

       NSLog(@"In segment 1");

       cell.textLabel.text=[phPatch objectAtIndex:indexPath.row];
       cell.selectionStyle = UITableViewCellSelectionStyleNone;

        UILabel *typeLabel = [[[UILabel alloc]init]autorelease];
        typeLabel.backgroundColor = [UIColor clearColor];
        typeLabel.text = [phName objectAtIndex:indexPath.row];
        typeLabel.textAlignment = UITextAlignmentCenter;
        typeLabel.frame = CGRectMake(300,2.0f,150,50);
        [cell addSubview:typeLabel];

        UILabel *typeLabel1 = [[[UILabel alloc]init]autorelease];
        typeLabel1.backgroundColor = [UIColor clearColor];
        typeLabel1.text = [phClass objectAtIndex:indexPath.row];
        typeLabel1.textAlignment = UITextAlignmentCenter;
        typeLabel1.frame = CGRectMake(400,2.0f,150,50);
        [cell addSubview:typeLabel1];


    }   
   }
   return cell;
  }

谢谢你。

4

2 回答 2

0

汇编代码没有多大帮助。

您收到此消息是因为您正在向已发布的对象发送消息。

要调试您而不是运行的不良访问权限,只需执行配置文件,然后选择僵尸对象。

这会将所有对象保留在内存中,并且应该向您显示错误的来源。

于 2013-09-19T13:13:01.120 回答
0

我设法解决了这个问题。问题出在

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
if(tableView == tableview1){

    NSInteger selectedSegment = segmentControl.selectedSegmentIndex;
    if(selectedSegment == 0)
        return @"               Doctor                                    Patch          Class                    Speciality";
    else                          <------ This Else was not there, the reason is was giving BAD ACCESS ERROR.
        return @""; 
}
  else
    return @"         Patch                     Pharmacy Name               Class";
}

无论如何,谢谢。

于 2013-09-27T04:54:18.993 回答