Ios 从UIImage更改ViewController
当按下图片中的某个区域时,我试图更改ViewController。 我试着这样做:Ios 从UIImage更改ViewController,ios,objective-c,uiimage,viewcontroller,Ios,Objective C,Uiimage,Viewcontroller,当按下图片中的某个区域时,我试图更改ViewController。 我试着这样做: -(void)openDrawer{ UIStoryboard *mStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *vc =[mStoryBoard instantiateViewControllerWithIdentifier:@"DrawViewCont
-(void)openDrawer{
UIStoryboard *mStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc =[mStoryBoard instantiateViewControllerWithIdentifier:@"DrawViewController"];
[self.navigationController pushViewController:vc animated:YES];
}
但是self.navigationController不存在,这是可以理解的,但是我找不到一种方法来获取图像中当前viewController的
我尝试将它放在另一个类中,从当前视图的viewController中进行委派
-(void) changeChangeViewToName:(NSString *)name{
UIStoryboard *mStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc =[mStoryBoard instantiateViewControllerWithIdentifier:name];
[self.navigationController pushViewController:vc animated:YES];
}
这在viewController内部工作,但我无法从图像内部调用该函数。发布一个来自类(图像?)的通知,该类决定要显示新的视图控制器。在现有视图控制器中侦听能够执行推送的通知。Phillip Mills是正确的。您还可以使用委托模式: