我是 iOS 开发的新手,目前坚持创建后退按钮。我已经在点击按钮上放置了 popViewControllerAnimated方法,我也在调试模式下对其进行了测试,并且后退按钮方法正在调用但popViewControllerAnimated不起作用。
这是代码。
- (void)viewDidLoad
{
[super viewDidLoad];
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake((self.view.frame.size.height-100), 30, 80, 20)];
[backButton setTitle:@"Back" forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(BackButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:backButton];
//some piece of code...
}//end of viewDidLoad method
-(void)BackButtonClicked: (id)sender{
[self.navigationController popViewControllerAnimated:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"testing" message:@"some message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:@"NO", nil];
[alert show];
}
在点击返回按钮时,此警报会显示,但屏幕不会返回。
任何有关此问题的帮助都将不胜感激。
我通过在我以前的 viewController 中编写这段代码来调用这个 viewController
PlaceTranslatedDetailsViewController *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"placeTranslatedDetail"];
[self presentViewController:secondViewController animated:YES completion:NULL];
然而,这个 viewController 和之前的 viewController 是通过编程设计的