如何使用PushViewController方法从UIViewClass导航到UIViewController类

时间:2013-02-25 11:10:23

标签: ios uiview uiviewcontroller uinavigationcontroller

我在UIView课程中有一个按钮,我需要使用UIViewController导航到NavigationViewController课程。我陷入了困境。谁能告诉我解决方案呢 根据用户评论进行修改

-(void)eventDetailView:(id)sender
{ 
  EventDetailPage *eventDetail = [[EventDetailPage alloc]initWithNibName:@"EventDetailPage" bundle:[NSBundle mainBundle]]; 
  [[[[self window] rootViewController] navigationController] pushViewController:eventDetail animated:YES]; 
 } 

1 个答案:

答案 0 :(得分:0)

你可以用它。它对我很有用: -

首先在UIView类中创建AppDelegate的对象并初始化它。 然后在Appdelegate.h中创建Navigationcontroller对象: -

@property(strong,nonatomic) UINavigationController *navControl;

在你的UIView类中,实现你要推送的代码: -

ViewController *objview = [[ViewController alloc]init];
    [appDelegate.navControl pushViewController:objview animated:YES];