【问题标题】:Switch views from alert view options in xcode从 xcode 中的警报视图选项切换视图
【发布时间】:2013-08-08 05:18:23
【问题描述】:

我想通过主页中显示的警报视图菜单按钮移动到情节提要中创建的其他视图。警报视图提供包含不同视图的按钮列表。
我怎样才能转向这些观点。
我正在使用

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1){

}
if (buttonIndex ==2) {

}
if(buttonIndex == 3){


}

}

【问题讨论】:

  • 你尝试过什么?这是一个非常基本的问题。您似乎不了解导航或情节提要的基本知识。这个网站不是用来学习基础的。当您在代码中遇到问题时提出问题,而不是学习如何编码。你可以从这里学习:raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
  • 如果您认为我不理解您的问题并且您的问题不是基本问题,请更新详细信息。

标签: objective-c xcode4.3


【解决方案1】:

首先,您需要获取情节提要的实例。
然后您使用情节提要实例化您的视图控制器。
然后你像往常一样推入导航堆栈。

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"storyboard_name" bundle:nil];

    if (buttonIndex == 1)
    {
        ViewController1 *vc1 = (ViewController1 *)[storyboard instantiateViewControllerWithIdentifier:@"view1"];
        [self.navigationcontroller pushViewController:vc1];
    }
    if (buttonIndex ==2)
    {
        ViewController2 *vc2 = (ViewController1 *)[storyboard instantiateViewControllerWithIdentifier:@"view2"];
        [self.navigationcontroller pushViewController:vc2];
    }
    if(buttonIndex == 3)
    {
    }
}

【讨论】:

    猜你喜欢
    • 2011-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多