从CFCoverFlowView推送视图控制器

时间:2014-07-30 15:02:09

标签: ios objective-c

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

我想要完成的是在单击不同图像时能够推送septet ViewControllers。我正在使用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

我想要做的是当点击图片时,ViewController会被StoryboardID推送。

当我尝试这个时,应用程序崩溃了:

- (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];
    }
}

所以,如果有人可以帮助我,我会非常感激,如果有任何遗漏,或者你不理解我的代码评论,我会编辑文本。

2 个答案:

答案 0 :(得分:1)

假设:您收到此错误;

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

解决方案:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

答案 1 :(得分:0)

这是一个错字还是你没有推动你实例化的ViewController的实例?您需要按 ViewController1

[self.navigationController pushViewController:ViewController1 animated:YES];