如何从UIView子类导航到其他UIViewController

时间:2012-02-04 13:41:50

标签: ios cocoa-touch navigationcontroller

小问题了。首先,我在this brilliant battle of intellect找到了,但唉,那里甚至没有接受的回答。和其他帖子一样。好吧,我需要从UIView导航到其他UIViewController。

我的代码:在-layoutSubviews中我创建了一个按钮

if(!setQualityButton)
{
    setQualityButton=[[[UIButton alloc]initWithFrame:CGRectMake(120.00,367.00,100,27)] autorelease];
    [self.setQualityButton setBackgroundImage:[UIImage imageNamed:@"btnGreen.png"] forState:UIControlStateNormal];

    [setQualityButton.layer setBorderColor: [[UIColor grayColor] CGColor]];
    [setQualityButton.layer setBorderWidth: 1.0];
    [setQualityButton.layer setCornerRadius:8.0f];
    [setQualityButton.layer setMasksToBounds:YES];

    [setQualityButton addTarget:self action:@selector(goToSetQualityView) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:setQualityButton];
}

和他自己的方法

-(void)goToSetQualityView
 {
   SetQualityView *sqv=[[SetQualityView alloc]initWithNibName:@"SetQualityView" bundle:nil];
   sqv.itemID=self.itemID;
   sqv.currentQuality=theItem.quality;
   [[[[self window] rootViewController] navigationController] pushViewController:sqv animated:YES];
   [sqv release];
 }

当我按下此按钮时,没有任何反应。我的意思是我没有被导航到其他视图而没有警告。

1 个答案:

答案 0 :(得分:0)

使视图控制器保持此视图的委托,并从中推送下一个viewcontroller。 Ot只提供viewcontrooler的导航控制器,它可以保存视图,所以它会用它来填充下一个viewcontroller。