在我的申请中,我有4 UIViewcontrollers
- A,B,C和D.
从我的UIViewController A
,可以呈现UIVIewControllers B或C或D.假设,从A,我已经呈现B.然后,在B上,有两个UIButtons
,点击它,我需要解雇B和现在C或解雇B和现在D.这发生成功,但是首先,在解雇B之后,A的屏幕出现,然后进入C或D.
这就是我所做的:
开启按钮按开启B,操作为:
{
UINavigationController *controller = (UINavigationController *)self.parentViewController;
NSLog(@"%@",[controller parentViewController]);
UITabBarController *tabBarReference = (UITabBarController *)[controller parentViewController];
HomePageViewController *presController = (HomePageViewController *)tabBarReference.presentingViewController;
[presController dismissTabControllerWithHandlerWithSenderAtIndex:1];
}
在A中,我有这些方法:
-(void)dismissTabControllerWithHandlerWithSenderAtIndex:(NSInteger)index
{
if(index == 0)
{
[self dismissViewControllerAnimated:NO completion:^{
[self aboutButtonPressed:self];
}];
}
else
{
[self dismissViewControllerAnimated:NO completion:^{
[self settingsButtonPressed:self];
}];
}
}
这是我打电话的方法..
- (IBAction)settingsButtonPressed:(id)sender
{
[self.contactUsView setHidden:YES];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *deviceType = [prefs objectForKey:@"DeviceType"];
NSString *iOSType = [prefs objectForKey:@"iOSType"];
if([iOSType isEqualToString:@"iOS7"])
{
if([deviceType isEqualToString:@"iPad"])
{
SettingsViewController *settingsPage = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController_iPad" bundle:NULL];
settingsPage.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:settingsPage animated:YES completion:NULL];
}
else
{
SettingsViewController *settingsPage = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:NULL];
settingsPage.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:settingsPage animated:YES completion:NULL];
}
}
else
{
if([deviceType isEqualToString:@"iPad"])
{
SettingsViewController *settingsPage = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController_iPad_iOS6" bundle:NULL];
settingsPage.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:settingsPage animated:YES completion:NULL];
}
else
{
SettingsViewController *settingsPage = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController_iOS6" bundle:NULL];
settingsPage.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:settingsPage animated:YES completion:NULL];
}
}
}
答案 0 :(得分:0)
好的,这里: -
假设viewcontroller
A是基础&它presents
view controllers
B或C。
实施必须解除视图控制器B或C的委托/通知。
发送代理人或发布通知后,请关闭当前的view controller without animation, i.e animation:NO
。
发布此通知需要在view controller
A
在这里,您将展示下一个视图控制器。
修改: - 强>
-(void)dismissTabControllerWithHandlerWithSenderAtIndex:(NSInteger)index
{
if(index == 0)
{
[self dismissViewControllerAnimated:NO completion:nil];
[self aboutButtonPressed:self];
}
else
{
[self dismissViewControllerAnimated:NO completion:nil];
[self settingsButtonPressed:self];
}
}