在视图控制器segue编程按钮之间切换

时间:2013-11-24 10:58:43

标签: ios segue viewcontroller

我有一个viewcontroller,我按程序制作按钮并将它们保存在一个数组中。当我第一次按下按钮并按下按钮时我可以使用seque转到下一个viewcontroller。但是当我按下数组中的按钮时(显示数组中的什么不是空的时候)它不起作用。它说:他的观点不在窗口层次结构中!

NSMutableArray *ArrayProduct; //extern array

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self FcRefreshView];

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

-(void) FcAddedButton:(int)Tagindex // make button
{

UIButton *EditButton = [UIButton buttonWithType: UIButtonTypeRoundedRect];
[EditButton setFrame:CGRectMake(220, 420, 86, 28) ];
[EditButton addTarget:self action:@selector(myActionClick:) forControlEvents:UIControlEventTouchUpInside];
[EditButton setTitle:@"Button" forState:UIControlStateNormal];
[EditButton setTag:Tagindex];
[self.view addSubview: EditButton];

[ArrayProduct addObject:EditButton];

}

-void) FcRefreshView //Load secone time all buttons
{

int i;

if (ArrayProduct.count <= 0)
{
    ArrayProduct = [[NSMutableArray alloc] init];
    [self FcAddedButton:0];
}
else
{
    for (i=0; i< ArrayProduct.count; i++) {
        [self.view addSubview:[ArrayProduct objectAtIndex:i]];
    }        
}
}

-(void) myActionClick:(id) sender //When i have a action
{    
[self performSegueWithIdentifier:@"goto3" sender:self];
}
@end

这是经过测试的代码,第一次按下按钮后就不行了! 它哪里出错?

0 个答案:

没有答案