다음 예를 확인하십시오. 도움이되기를 바랍니다.
#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
영어 문장은 거의 이해가되지 않습니다. "이 양식으로 이동할 때"양식이란 무엇입니까? "버튼을 저장할 수 있습니다"버튼을 저장 하시겠습니까? 그게 무슨 뜻 이죠? –
@EI Tomato, 순수한 영어를 알고 이해한다면 어떤 문법상의 실수라도 발견하면 질문을 편집 할 수 있습니다. 사실 나는 영어가 조금 약하다. –
[UITextField 텍스트 변경 이벤트] 가능한 복제본 (https://stackoverflow.com/questions/7010547/uitextfield-text-change-event) –