1

我是iOS的初学者。当我运行我的 xcode 模拟器并单击文本字段时,我在文本字段上设置了表格,但是当我单击时,表格无法打开并且显示错误是EXC_BADAccess (code1) or EXC_Breakpoint(i1300..).

为什么会这样?

这是我得到的图像。

在此处输入图像描述

        UITextfield *Delivery_Staff;
        UITableView *tabel_AdviseTest;
        Delivery_Staff=[[UITextField alloc]initWithFrame:CGRectMake(160,470,140,30)];
        Delivery_Staff.font = [UIFont boldSystemFontOfSize:15.0];
        Delivery_Staff.placeholder = @"<Select Delivery Staff>" ;
        Delivery_Staff.borderStyle = UITextBorderStyleLine;
        Delivery_Staff.delegate =self;
        Delivery_Staff.tag=5;
        [scrollview addSubview:Delivery_Staff];
        tabel_AdviseTest=[[UITableView alloc]initWithFrame:CGRectMake(520,700,190,300)  style:UITableViewStylePlain];
        tabel_AdviseTest.delegate=self;
        tabel_AdviseTest.dataSource=self;
        [scrollview addSubview:tabel_AdviseTest];
        tabel_AdviseTest.hidden=YES;



        UILabel *PatientSearch=[[UILabel alloc]initWithFrame:CGRectMake(20,10,120,40)];
        PatientSearch.font = [UIFont systemFontOfSize:15.0];
        PatientSearch.backgroundColor=[UIColor whiteColor];
        [PatientSearch setText:@"Search Patient:"];
        [view1 addSubview:PatientSearch];

        patientname=[[UITextField alloc]initWithFrame:CGRectMake(130,10,170,40)];
        patientname.font = [UIFont boldSystemFontOfSize:15.0];
       //the horizontal alignment of the text
        patientname.textAlignment = NSTextAlignmentLeft;
        patientname.borderStyle = UITextBorderStyleBezel;
        patientname.contentVerticalAlignment =    UIControlContentHorizontalAlignmentCenter;
        patientname.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
        patientname.delegate =self;
        [view1 addSubview:patientname];


         [patientname addTarget:self action:@selector(SearchPatients:)forControlEvents:UIControlEventEditingChanged];

       -(IBAction)SearchPatients:(id)sender
        {
          [Testname removeFromSuperview];
          [table_SearchPatient removeFromSuperview];
          [tabel_AdviseTest removeFromSuperview];
          PatientName=patientname.text;
          NSLog(@"patname %@",PatientName);
          Count=@"0";
        NSLog(@"patname %@",self.WebService->patientname=PatientName);
        NSLog(@"count %@",self.WebService->count=Count);

        [self.WebService CallServicePatientNames:@"http://192.168.1.202:81/PatientModule/PatientService.asmx/SearchPatientjquery" Object:NULL Handler:NULL];


       table_SearchPatient=[[UITableView alloc]initWithFrame:CGRectMake(130,50,170,200)style:UITableViewStylePlain];
       table_SearchPatient.delegate=self;
       table_SearchPatient.dataSource=self;
       table_SearchPatient.layer.borderWidth = 2.0;
       table_SearchPatient.layer.borderColor = [UIColor grayColor].CGColor;
       [self.view addSubview:table_SearchPatient];
       SearchPatientDetail=[[NSMutableArray alloc]init];
       SearchPatientName=[[NSMutableArray alloc]init];
       NSLog(@"arr is %@",self.WebService->ptr1);
      SearchPatientDetail=(NSMutableArray*)self.WebService->ptr1 ;
    // NSLog(@"item is %@",   SearchPatientDetail);
      SearchPatientName  =(NSMutableArray *)[SearchPatientDetail valueForKey:@"Name"];
      NSLog(@"item is %@",SearchPatientName);


// Do any additional setup after loading the view from its nib.

}

我已经创建了 5-6 次类似的自定义表格,并且还在同一个视图控制器上添加了 7-8 个文本字段。实际上我发布到 webservice url,然后根据这个在数组中获取数据并点击文本字段。然后它打开表并相应地从中选择数据。这点击了 5-6 个网址,并在这里做同样的事情。这些字段是自定义创建的。
提前致谢

4

0 回答 0