【问题标题】:Error linking button错误链接按钮
【发布时间】:2012-07-14 18:14:57
【问题描述】:

我一整天都在努力解决这个问题,最后只出现了一个错误 这是一个图像。

【问题讨论】:

    标签: ios xcode4 xcode4.3 uialertview alert


    【解决方案1】:

    alertView 仍然缺少大括号。

    另外,您不要在showAlert 的声明中使用()

    我建议您适当地使用标签,以便更容易看到丢失的大括号。从长远来看,它会对您有所帮助。此外,发布的代码本身而不是图像更有帮助,然后我们可以自己复制/粘贴来编辑它。

    编辑

    它应该是这样的,格式正确。此外,我认为在这种情况下,代理应该设置为 self 而不是 nil,所以我做对了。

    您应该采用一种编程风格,让您可以轻松查看缺少大括号之类的内容。如果下面缺少任何大括号,那将是非常明显的,因为是标签样式。

    -(void)showAlert 
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"hello"
                                                        message:@"what's your name"
                                                       delegate:self
                                              cancelButtonTitle:@"Dismiss"
                                              otherButtonTitles:@"apple", @"google", @"yahoo", nil];
        [alert show];
    }   
    
    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        if(buttonIndex == 1)
        {
            //...
        }
        else if(buttonIndex == 2)
        {
            //...
        }
        else if(buttonIndex == 3)
        {
            //...
        }
    }
    

    【讨论】:

    • @Picm 还有()alertView(): 是错误的。就像我说的,没有() 用于声明。此外,您没有前一种方法的结束大括号,[alert show]; 之后应该有一个}
    • 对不起,我很新,现在呢
    • @Picm 在那里,你去吧,这就是你应该拥有的。
    【解决方案2】:

    您没有在错误 (showAlert) 之前关闭方法的大括号。

    【讨论】:

    • 请你看看我编辑的问题,你不知道出了什么问题吗??
    • 你读过我的回答吗?错误在于您没有关闭 大括号,而不是您没有打开 括号。 ..
    【解决方案3】:

    您缺少用于 showAlert() 的终止花括号。

    【讨论】:

    • 请你看看我编辑的问题,你不知道出了什么问题吗??
    【解决方案4】:
    -(void) showAlert {
    
    }   
    
     -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多