您好,我正在开发一个应用程序,其中正在使用名为CFCoverFlowView的第三方库(无法链接它,但是如果您只是Google CFCoverFlowView,则可以找到GitHub网站)。

我要完成的任务是能够在单击不同图像时推动septet ViewController。我正在使用Storyboard,所以我想使用

instantiateViewControllerWithIdentifier:@""

在库中,单击图像时将获得以下行:
- (void)coverFlowView:(CFCoverFlowView *)coverFlowView didSelectPageItemAtIndex:(NSInteger)index;

而且我这样做是为了确保它可以与UIAlertView一起使用:
- (void)coverFlowView:(CFCoverFlowView *)coverFlowView didSelectPageItemAtIndex:(NSInteger)index;
{

if (index == 0)
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"0" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];

}

if (index == 1)
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"1" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];

}

if (index == 2)
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"2" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];

}

if (index == 3)
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"3" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];

}

if (index == 4)
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"4" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];

    }

}

并且有效,当我单击单独的图像时,我得到了这个图像(因为这是我的第一个问题,由于我的声誉低下,我不能发布图像或超过2个链接。)

图片1 http://i60.tinypic.com/k1e4wz.png
图片2 http://i59.tinypic.com/1g6lif.png

我想做的是单击图像时按下带有ViewControllerStoryboardID

当我尝试此应用程序崩溃时:
- (void)coverFlowView:(CFCoverFlowView *)coverFlowView didSelectPageItemAtIndex:(NSInteger)index;
{
    if (index == 0)
    {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main.storyboard" bundle:nil];
    UIViewController *ViewController1 = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];
    [self.navigationController pushViewController:ViewController1 animated:YES];
    }
}

因此,如果有人可以帮助我,将不胜感激,如果缺少任何内容,或者您​​不理解我的代码注释,我将编辑文本。

最佳答案

假设:您遇到此错误;

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main.storyboard'

解决方案:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

07-26 05:24