2017-10-27 7 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の代わりに私はいくつかの他のライブラリを使用しています。ありがとう@ニキータ –

0

フィールド数が0より大きいかどうかをチェックして、バリデータ関数を使用してフォーム全体を検証します。RAFieldValidatorなど、いくつかのバリデータがあります。 githubの詳細を調べてください。テキストフィールドの

に、この機能をトリガに来https://github.com/search?utf8=%E2%9C%93&q=form+validator+ios&type=

をこれらをチェックアウト:、TextViewのためにUITextField text change event

をこのチェックアウト:それのメソッドを:あなたはUITextViewデリゲートを設定し、textViewDidChangeを実装する必要があります。

関連する問題