2017-10-27 3 views
0

여기에 모든 UITextfield하고 설명 필드가 UITextView입니다 설명 필드를 제외하고 내보기,이보기에서 enter image description here어떻게 알 수 있습니까? UITextField 및 UITextView에서는 변경/수정이 완료 되었습니까?

이다.

그래서 내가 원하는 나는이보기로 이동하는 경우,

  1. 가 난 단지 버튼을
  2. 을 활성화 그리고 일부 필드 '값을 편집 한 경우 및 시도됩니다 저장 한 후 일부 내용을 변경 또는 수정 한 경우이다 저장하지 않고 이전 화면으로 돌아가려면 경고가 나타나야합니다.

enter image description here

어떻게 그것을 달성하기 위해? 감사.

+0

영어 문장은 거의 이해가되지 않습니다. "이 양식으로 이동할 때"양식이란 무엇입니까? "버튼을 저장할 수 있습니다"버튼을 저장 하시겠습니까? 그게 무슨 뜻 이죠? –

+0

@EI Tomato, 순수한 영어를 알고 이해한다면 어떤 문법상의 실수라도 발견하면 질문을 편집 할 수 있습니다. 사실 나는 영어가 조금 약하다. –

+0

[UITextField 텍스트 변경 이벤트] 가능한 복제본 (https://stackoverflow.com/questions/7010547/uitextfield-text-change-event) –

답변

0

다음 예를 확인하십시오. 도움이되기를 바랍니다.

#import "SampleViewController.h" 

@interface SampleViewController() 

@end 

@implementation SampleViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    _textview.delegate = self; 

    _secondButton.hidden = YES; 

    self.textview.layer.borderWidth = 2.0f; 
    self.textview.layer.borderColor = [[UIColor grayColor] CGColor]; 

    self.navigationItem.hidesBackButton = YES; 
    UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle:@"< back" style:UIBarButtonItemStylePlain target:self action:@selector(back:)]; 
    self.navigationItem.leftBarButtonItem = newBackButton; 


} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (void)textViewDidBeginEditing:(UITextView *)textView{ 
    _secondButton.hidden = NO; 
} 

- (void) back:(UIBarButtonItem *)sender { 
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Attention" 
                    message:@"Are you sure want to discard this message." 
                  preferredStyle:UIAlertControllerStyleAlert]; 

    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault 
                  handler:^(UIAlertAction * action) { 
                   self.textview.text = nil; 
                   [self.navigationController popViewControllerAnimated:YES]; 
                  }]; 

    [alert addAction:defaultAction]; 
    [self presentViewController:alert animated:YES completion:nil]; 
    NSLog(@"sandip"); 
    [self.navigationController popViewControllerAnimated:YES]; 
} 

- (IBAction)secondButton:(id)sender { 
} 
@end 
+0

을 작성하는 데 사용한 데이터와 비교하여 확인하고 알려주십시오. –

+0

그것은 나를 위해 작동하지만 UIAlertAction 대신 다른 라이브러리를 사용하고 있습니다. 고맙습니다. @nikita –

0

유효성 검사기 기능을 사용하여 텍스트 필드 수가> 0인지 확인하여 전체 양식의 유효성을 검사합니다. 더 쉽게 사용할 수 있도록 RAFieldValidator와 같은 몇 가지 유효성 검사기가 있습니다. github에 대한 자세한 내용을보십시오. 밖으로 텍스트 필드에이 기능을

을 유발 오는 https://github.com/search?utf8=%E2%9C%93&q=form+validator+ios&type=

다음을 확인하십시오, 텍스트 뷰를 들어 UITextField text change event

를이 체크 아웃 : 당신은 textViewDidChange를 UITextView 대리자를 설정하고 구현해야합니다 방법을 거기에.

관련 문제