Событие касания не работает для кнопки и текста в iOS Objective-C

user3452 спросил: 31 августа 2018 в 09:58 в: ios

У меня есть кнопка и текстовое представление, которое я добавляю динамически при нажатии кнопки добавления. Но новый текст и кнопка, которые я добавил, не распознают мое прикосновение. Я все-таки создал распознавание событий, но все-таки событие touch не обрабатывается. Прикосновение в текстовом виде, которое отмечено красным цветом, не работает.

Также кнопка "Добавить и удалить" не работает. Я создал событие касания для этого, но сама функция не вызвана, что означает, что она не принимает сенсорный жест. Это мой код

- (void)RemoveChemical1Tapped:(UIButton *)sender {    _ans6Constraint.constant = 340;
    [self reloadTable];} - (void)viewDidLoad{
        @try{
        [super viewDidLoad];        if(self.isReceived==true){
            [_HSSwitch setEnabled:NO];
        }            [_addChemical addTarget:self action:@selector(addChemicalTapped:) forControlEvents:UIControlEventTouchUpInside];
             [_RemoveChemical1 addTarget:self action:@selector(RemoveChemical1Tapped:) forControlEvents:UIControlEventTouchUpInside];         // NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:_ans6Text4 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:100];
        UILabel *titleLbl = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
        [titleLbl setText:@"Questionnaire"];
        [titleLbl setTextColor:[UIColor whiteColor]];
        [titleLbl setFont:[UIFont fontWithName:@"OpenSans-Semibold" size:17.0]];
        [self.navigationItem setTitleView:titleLbl];        [self.navigationController setNavigationBarHidden:NO];
        [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:63.0/255.0 green:29.0/255.0 blue:11.0/255.0 alpha:1.0]];
        UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
        [backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [backButton addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc]initWithCustomView:backButton];
        [self.navigationItem setLeftBarButtonItem:backBarButton];        if (!self.isLiteNVD) {
            UIButton *saveButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
            [saveButton setImage:[UIImage imageNamed:@"PropertyFence"] forState:UIControlStateNormal];
            [saveButton addTarget:self action:@selector(save:) forControlEvents:UIControlEventTouchUpInside];
            UIBarButtonItem *saveBarButton = [[UIBarButtonItem alloc] initWithCustomView:saveButton];
            [self.navigationItem setRightBarButtonItem:saveBarButton];
        }        _datePicker = [[UIDatePicker alloc]init];
        [_datePicker setBackgroundColor:[UIColor whiteColor]];
        [_datePicker setDatePickerMode:UIDatePickerModeDate];
        [_datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];        _datePickerPast = [[UIDatePicker alloc]init];
        [_datePickerPast setBackgroundColor:[UIColor whiteColor]];
        [_datePickerPast setDatePickerMode:UIDatePickerModeDate];
        [_datePickerPast setMaximumDate:[NSDate date]];
        [_datePickerPast addTarget:self action:@selector(pastDateChanged:) forControlEvents:UIControlEventValueChanged];        UIView *paddingView1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans3Text1 setClipsToBounds:NO];
        [_ans3Text1.layer setBorderWidth:1.0];
        [_ans3Text1.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans3Text1.layer setCornerRadius:4.0];
        [_ans3Text1 setLeftView:paddingView1];
        [_ans3Text1 setLeftViewMode:UITextFieldViewModeAlways];        UIView *paddingView13 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans4Text1 setClipsToBounds:NO];
        [_ans4Text1.layer setBorderWidth:1.0];
        [_ans4Text1.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans4Text1.layer setCornerRadius:4.0];
        [_ans4Text1 setLeftView:paddingView13];
        [_ans4Text1 setLeftViewMode:UITextFieldViewModeAlways];        UIView *paddingView14 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans4Text2 setClipsToBounds:NO];
        [_ans4Text2.layer setBorderWidth:1.0];
        [_ans4Text2.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans4Text2.layer setCornerRadius:4.0];
        [_ans4Text2 setLeftView:paddingView14];
        [_ans4Text2 setLeftViewMode:UITextFieldViewModeAlways];
        [_ans4Text2 setInputView:_datePickerPast];        [_ans4ImageView setClipsToBounds:YES];
        [_ans4ImageView.layer setBorderWidth:1.0];
        [_ans4ImageView.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans4ImageView.layer setCornerRadius:4.0];        [_ans4Button setClipsToBounds:NO];
        [_ans4Button.layer setBorderWidth:1.0];
        [_ans4Button.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans4Button.layer setCornerRadius:4.0];        UIView *paddingView2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans5Text1 setClipsToBounds:NO];
        [_ans5Text1.layer setBorderWidth:1.0];
        [_ans5Text1.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans5Text1.layer setCornerRadius:4.0];
        [_ans5Text1 setLeftView:paddingView2];
        [_ans5Text1 setLeftViewMode:UITextFieldViewModeAlways];        UIView *paddingView3 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans6Text1 setClipsToBounds:NO];
        [_ans6Text1.layer setBorderWidth:1.0];
        [_ans6Text1.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans6Text1.layer setCornerRadius:4.0];
        [_ans6Text1 setLeftView:paddingView3];
        [_ans6Text1 setLeftViewMode:UITextFieldViewModeAlways];
            UIView *paddingView3new1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
            [_Ans6Text1new1 setClipsToBounds:NO];
            [_Ans6Text1new1.layer setBorderWidth:1.0];
            [_Ans6Text1new1.layer setBorderColor:[UIColor whiteColor].CGColor];
            [_Ans6Text1new1.layer setCornerRadius:4.0];
            [_Ans6Text1new1 setLeftView:paddingView3new1];
            [_Ans6Text1new1 setLeftViewMode:UITextFieldViewModeAlways];        UIView *paddingView4 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans6Text2 setClipsToBounds:NO];
        [_ans6Text2.layer setBorderWidth:1.0];
        [_ans6Text2.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans6Text2.layer setCornerRadius:4.0];
        [_ans6Text2 setLeftView:paddingView4];
        [_ans6Text2 setLeftViewMode:UITextFieldViewModeAlways];
        [_ans6Text2 setInputView:_datePicker];
            UIView *paddingView4new1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
            [_Ans6Text2new1 setClipsToBounds:NO];
            [_Ans6Text2new1.layer setBorderWidth:1.0];
            [_Ans6Text2new1.layer setBorderColor:[UIColor whiteColor].CGColor];
            [_Ans6Text2new1.layer setCornerRadius:4.0];
            [_Ans6Text2new1 setLeftView:paddingView4new1];
            [_Ans6Text2new1 setLeftViewMode:UITextFieldViewModeAlways];
            [_Ans6Text2new1 setInputView:_datePicker];        UIView *paddingView5 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans6Text3 setClipsToBounds:NO];
        [_ans6Text3.layer setBorderWidth:1.0];
        [_ans6Text3.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans6Text3.layer setCornerRadius:4.0];
        [_ans6Text3 setLeftView:paddingView5];
        [_ans6Text3 setLeftViewMode:UITextFieldViewModeAlways];
            UIView *paddingView5new1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
            [_Ans6Text3new1 setClipsToBounds:NO];
            [_Ans6Text3new1.layer setBorderWidth:1.0];
            [_Ans6Text3new1.layer setBorderColor:[UIColor whiteColor].CGColor];
            [_Ans6Text3new1.layer setCornerRadius:4.0];
            [_Ans6Text3new1 setLeftView:paddingView5new1];
            [_Ans6Text3new1 setLeftViewMode:UITextFieldViewModeAlways];        UIView *paddingView6 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans6Text4 setClipsToBounds:NO];
        [_ans6Text4.layer setBorderWidth:1.0];
        [_ans6Text4.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans6Text4.layer setCornerRadius:4.0];
        [_ans6Text4 setLeftView:paddingView6];
        [_ans6Text4 setLeftViewMode:UITextFieldViewModeAlways];
            UIView *paddingView6new1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
            [_Ans6Text4new1 setClipsToBounds:NO];
            [_Ans6Text4new1.layer setBorderWidth:1.0];
            [_Ans6Text4new1.layer setBorderColor:[UIColor whiteColor].CGColor];
            [_Ans6Text4new1.layer setCornerRadius:4.0];
            [_Ans6Text4new1 setLeftView:paddingView6new1];
            [_Ans6Text4new1 setLeftViewMode:UITextFieldViewModeAlways];        UIView *paddingView7 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans7Text5 setClipsToBounds:NO];
        [_ans7Text5.layer setBorderWidth:1.0];
        [_ans7Text5.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans7Text5.layer setCornerRadius:4.0];
        [_ans7Text5 setLeftView:paddingView7];
        [_ans7Text5 setLeftViewMode:UITextFieldViewModeAlways];
        [_ans7Text5 setInputView:_datePickerPast];        UIView *paddingView8 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans7Text1 setClipsToBounds:NO];
        [_ans7Text1.layer setBorderWidth:1.0];
        [_ans7Text1.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans7Text1.layer setCornerRadius:4.0];
        [_ans7Text1 setLeftView:paddingView8];
        [_ans7Text1 setLeftViewMode:UITextFieldViewModeAlways];        UIView *paddingView9 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans7Text2 setClipsToBounds:NO];
        [_ans7Text2.layer setBorderWidth:1.0];
        [_ans7Text2.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans7Text2.layer setCornerRadius:4.0];
        [_ans7Text2 setLeftView:paddingView9];
        [_ans7Text2 setLeftViewMode:UITextFieldViewModeAlways];
        [_ans7Text2 setInputView:_datePickerPast];        UIView *paddingView10 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans7Text3 setClipsToBounds:NO];
        [_ans7Text3.layer setBorderWidth:1.0];
        [_ans7Text3.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans7Text3.layer setCornerRadius:4.0];
        [_ans7Text3 setLeftView:paddingView10];
        [_ans7Text3 setLeftViewMode:UITextFieldViewModeAlways];        UIView *paddingView11 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans7Text4 setClipsToBounds:NO];
        [_ans7Text4.layer setBorderWidth:1.0];
        [_ans7Text4.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans7Text4.layer setCornerRadius:4.0];
        [_ans7Text4 setLeftView:paddingView11];
        [_ans7Text4 setLeftViewMode:UITextFieldViewModeAlways];
        [_ans7Text4 setInputView:_datePickerPast];        UIView *paddingView12 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
        [_ans8Text1 setClipsToBounds:NO];
        [_ans8Text1.layer setBorderWidth:1.0];
        [_ans8Text1.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans8Text1.layer setCornerRadius:4.0];
        [_ans8Text1 setLeftView:paddingView12];
        [_ans8Text1 setLeftViewMode:UITextFieldViewModeAlways];
        [_ans8Text1 setInputView:_datePickerPast];        [_ans9Text1.layer setBorderWidth:1.0];
        [_ans9Text1.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_ans9Text1.layer setCornerRadius:4.0];
        [_lastAnswers.layer setCornerRadius:4.0];
        [_ntButton.layer setCornerRadius:4.0];
        [_resetAll.layer setCornerRadius:4.0];
        [_msaBtn.layer setCornerRadius:4.0];
        [_gapButton.layer setCornerRadius:4.0];
        [_neButton.layer setCornerRadius:4.0];        [_submitButton.layer setBorderWidth:1.0];
        [_submitButton.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_submitButton.layer setCornerRadius:4.0];        [_HSBtn.layer setCornerRadius:4.0];
        [_nfasBtn.layer setCornerRadius:4.0];          //[self.tableView beginUpdates];
           // [self.view addConstraints:@[ top]];
    //        [self.view bringSubviewToFront:_addChemical];
    //
    //        [self reloadTable];
    //        [self.tableView reloadData];
           // [self.tableView bringSubviewToFront: _addChemical];
    //        NSArray *arr = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:_questionArr.count-1 inSection:0]];
    //
    //        [self.tableView insertRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationAutomatic];
            //[self.tableView endUpdates];        NSDictionary *attrDict = @{
                                   NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue" size:13.0],
                                   NSForegroundColorAttributeName : [UIColor yellowColor]
                                   };
        NSMutableAttributedString * string = [[NSMutableAttributedString alloc] initWithString:@"I agree with declaration * "];
        [string addAttributes:attrDict range:NSMakeRange(0,25)];
        [string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(25,1)];
        [string addAttribute:NSExpansionAttributeName value:@-1 range:NSMakeRange(25,1)];
        [_DeclarationLbl setAttributedText:string];
        [_consDeclarationBtn.layer setCornerRadius:4.0];        [_signatureView.layer setBorderWidth:1.0];
        [_signatureView.layer setBorderColor:[UIColor whiteColor].CGColor];
        [_signatureView.layer setCornerRadius:4.0];        self.tableView.rowHeight = UITableViewAutomaticDimension;
        self.tableView.estimatedRowHeight = 100;        NSDictionary *userDic = [[DBHelper getSharedInstance] getCurrentUser];        if (self.operationType == OperationType_Quick){            if ([self.answersDic objectForKey:@"ResponsibleContactSignature"]) {
                UIImage *consImage = [self.answersDic objectForKey:@"ResponsibleContactSignature"];
                self.signImg.image = consImage;
                [self.consDeclarationSwitch setOn:YES];
            }
            else if (![[userDic objectForKey:@"UserSignaturePath"] isKindOfClass:[NSNull class]]) {
                NSString *dbPath = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
                UIImage *consImage = [UIImage imageWithContentsOfFile:[dbPath stringByAppendingPathComponent:[userDic objectForKey:@"UserSignaturePath"]]];
                self.signImg.image = consImage;
                [self.consDeclarationSwitch setOn:YES];
            }
            else{
                [self.signImg setImage:[UIImage imageNamed:@"signature"]];
            }
        }
        else if (self.operationType == OperationType_Edit){            if (![[self.NVDDic objectForKey:@"ResponsibleContactSignature"] isKindOfClass:[NSNull class]]) {
                NSString *ENVDPath = [[DBHelper getSharedInstance] ENVDPath];
                UIImage *consImage = [UIImage imageWithContentsOfFile:[ENVDPath stringByAppendingPathComponent:[self.NVDDic objectForKey:@"ResponsibleContactSignature"]]];
                self.signImg.image = consImage;
            }
            else{
                [self.signImg setImage:[UIImage imageNamed:@"signature"]];
            }
            if (![[self.NVDDic objectForKey:@"DeclarerAcknowledgement"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"DeclarerAcknowledgement"] boolValue]) {
                [self.consDeclarationSwitch setOn:YES];
            }
        }
        else if (![[userDic objectForKey:@"UserSignaturePath"] isKindOfClass:[NSNull class]]) {            NSString *dbPath = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
            UIImage *consImage = [UIImage imageWithContentsOfFile:[dbPath stringByAppendingPathComponent:[userDic objectForKey:@"UserSignaturePath"]]];
            self.signImg.image = consImage;
            [self.consDeclarationSwitch setOn:YES];
        }
        else{
            [self.signImg setImage:[UIImage imageNamed:@"signature"]];
        }        [self.nfasSwitch setEnabled:NO];
        [_nfasBtn setHidden:YES];        if (![[self.NVDDic objectForKey:@"HasNFASQuestion"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"HasNFASQuestion"] boolValue]) {
            self.hasNFAS=TRUE;
           // [_nfasSwitch setOn:YES];
           //[_nfasBtn setHidden:NO];
            [_nfasSwitch setOn:YES];
            [_nfasBtn setHidden:YES];
        }
        else{
            [_nfasSwitch setOn:NO];
            [_nfasBtn setHidden:YES];
        }        if (![[self.NVDDic objectForKey:@"HasHealthStatement"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"HasHealthStatement"] boolValue]) {
            if(self.isReceived==true){
                [_HSSwitch setOn:YES];
                [_HSBtn setHidden:YES];
               self.isReceivedHasHealthStatement=true;
             }else{
                 [_HSSwitch setOn:YES];
                 [_HSBtn setHidden:NO];
             }
        }
        else{
            [_HSSwitch setOn:NO];
            [_HSBtn setHidden:YES];
        }        if (![[NSUserDefaults standardUserDefaults] boolForKey:@"CanAccessAccreditation"]) {            [self.ntButton setHidden:YES];            [_msaBtn setHidden:YES];
            [_msaSwitch setOn:NO];
            [_msaSwitch setHidden:YES];
            [_msaLbl setHidden:YES];            [_hasGAP setHidden:YES];
            [_hasGAP setOn:NO];
            [_gapButton setHidden:YES];
            [_gapLbl setHidden:YES];            [_hasNE setHidden:YES];
            [_hasNE setOn:NO];
            [_neButton setHidden:YES];
            [_neLbl setHidden:YES];
            //[_NFASView setHidden: FALSE];            _signatureConstraint.constant = 10;
            //_NFASHeightConstraint.constant = 0;            [_NVDDic setObject:[NSNumber numberWithBool:NO] forKey:@"HasMSAQuestion"];
        }
        else {            int height = 10;            if (([self.NVDDic objectForKey:@"ConsignorState"] && ![[self.NVDDic objectForKey:@"ConsignorState"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"ConsignorState"] isEqualToString:@"NT"]) || ([self.NVDDic objectForKey:@"DestinationState"] && ![[self.NVDDic objectForKey:@"DestinationState"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"DestinationState"] isEqualToString:@"NT"]) || ([self.NVDDic objectForKey:@"HasNTWaybill"] && [[self.NVDDic objectForKey:@"HasNTWaybill"] boolValue])) {                [self.ntButton setHidden:NO];                height = height + 46;
            }
            else{
                [self.ntButton setHidden:YES];
            }            if (![[self.NVDDic objectForKey:@"HasMSAQuestion"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"HasMSAQuestion"] boolValue]) {
                [_msaSwitch setOn:YES];
                [_msaBtn setHidden:NO];                _msaConstraint.constant = height;
                height = height + 46;
            }
            else{
                [_msaSwitch setOn:NO];
                [_msaSwitch setHidden:YES];
                [_msaBtn setHidden:YES];
                [_msaLbl setHidden:YES];
            }            if (![[self.NVDDic objectForKey:@"IsGAPAccredited"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"IsGAPAccredited"] boolValue]) {
                [self.hasGAP setOn:YES];
                [self.gapButton setHidden:NO];                _gapConstraint.constant = height;
                height = height + 46;
            }
            else{
                [_hasGAP setOn:NO];
                [_hasGAP setHidden:YES];
                [_gapButton setHidden:YES];
                [_gapLbl setHidden:YES];
            }            if (![[self.NVDDic objectForKey:@"IsNEAccredited"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"IsNEAccredited"] boolValue]) {
                [_hasNE setOn:YES];
                [_neButton setHidden:NO];                _neConstraint.constant = height;
                height = height + 46;
            }
            else{
                [_hasNE setOn:NO];
                [_hasNE setHidden:YES];
                [_neButton setHidden:YES];
                [_neLbl setHidden:YES];
            }
            _signatureConstraint.constant = height;
        }        if (![[self.NVDDic objectForKey:@"HasESC"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"HasESC"] boolValue]) {
            [_hasESC setOn:YES];
        }
        else{
            [_hasESC setOn:NO];
        }        if (![[self.NVDDic objectForKey:@"HasTPA"] isKindOfClass:[NSNull class]] && [[self.NVDDic objectForKey:@"HasTPA"] boolValue]) {
            [_hasTPA setOn:YES];
        }
        else{
            [_hasTPA setOn:NO];
        }        if ([self.answersDic allKeys].count > 0) {
            [self loadQuestionaires];
        }        if (_operationType != OperationType_Edit) {            [_hasGAP setOn:NO];
            [self showGAP:_hasGAP];            [_hasNE setOn:NO];
            [self showNE:_hasNE];
        }        if (self.arrNFASSummary != nil){
            for (int i = 0; i < [self.arrNFASSummary count];i++){
                NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:[self.arrNFASSummary objectAtIndex:i]];
                if ([dict valueForKey:@"Dentition"] != nil)
                    [dict setValue:@"" forKey:@"Dentition"];
                if ([dict valueForKey:@"FeedDays"] != nil)
                    [dict setValue:[NSNumber numberWithInteger:0] forKey:@"FeedDays"];
            }
        }        NSString *statementQuery = [NSString stringWithFormat:@"SELECT * FROM CattleHealthStatementDetail WHERE NVDId = '%@'",[self.NVDDic objectForKey:@"NVDId"]];
        NSDictionary *dictHS = [[DBHelper getSharedInstance] getDetailsBySQL:statementQuery];
        if (dictHS != nil){
            [_NVDDic setObject:dictHS forKey:@"HSAnswers"];
        }
        }
        @catch (NSException *exception) {
            NSLog(@"%@", exception.reason);
        }
        }

Я думаю, что что-то не так с UI-кодом. Это код для вызова представления при щелчке сегмента. Думаю, мне нужно сделать измените здесь.

else if ([sender isEqual:_ans6Segment]) {        if (_ans6Segment.selectedSegmentIndex == 1) {            _ans6Text1.text = @"";
            _Ans6Text1new1.text=@"";
            _ans6Text2.text = @"";
          _Ans6Text2new1.text=@"";
            _ans6Text3.text = @"";
            _Ans6Text3new1.text=@"";
            _ans6Text4.text = @"";
            _Ans6Text4new1.text=@"";
            _ans6Constraint.constant = 5;
        }
        else {            _ans6Constraint.constant = 340;            [self.tableView bringSubviewToFront: _addChemical];
            NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:_addChemical attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:100];
            [self.view addConstraints:@[ top]];
        }
    }

Также есть большое белое пространство, которое появляется в представлении, я не знаю, откуда оно происходит, связано ли это с этой проблемой. попробовал уменьшить ось Y и ширину, чтобы удалить это пустое пространство, но ничего не получилось, вы можете увидеть, что inThis image опубликовал снимок экрана моего макета.

Это скриншот

Я знаю, что что-то не так с макетом, который является моим классом UIView. Поскольку идентификатор текстового поля доступен в другом текстовом поле в другом макете.


0 ответов