我有2個ViewControllers。登錄後,它將移動到下一個屏幕。然後會出現一個註銷按鈕。用戶按下注銷按鈕後,它應該返回到登錄屏幕,並顯示一個空的文本字段。如何註銷[iOS]
我該怎麼做?我嘗試了所有方法,但似乎並不奏效。
我的第一個視圖控制器:
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.sampleDictionary = @{@"username":@"alex", @"password":@"1234"};
}
- (IBAction)loginTapped
{
if ([self.sampleDictionary[@"password"] isEqualToString:passwordField.text]) {
[self performSegueWithIdentifier:@"ss" sender:self];
} else {
// Alert message
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"wrong" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *actionOk = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:actionOk];
[self presentViewController:alertController animated:YES completion:nil];
}
}
@end
這是我第二的ViewController:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.hidesBackButton = YES;
}
- (IBAction)logout:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
那麼問題出在哪裏?它不回去?這些字段不是空的?或者是什麼... – emotality
註銷不起作用 – jj1
它怎麼不起作用?什麼是不發生什麼假設發生? – emotality