【发布时间】:2012-07-14 18:14:57
【问题描述】:
我一整天都在努力解决这个问题,最后只出现了一个错误 这是一个图像。
【问题讨论】:
标签: ios xcode4 xcode4.3 uialertview alert
我一整天都在努力解决这个问题,最后只出现了一个错误 这是一个图像。
【问题讨论】:
标签: ios xcode4 xcode4.3 uialertview alert
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)
{
//...
}
}
【讨论】:
(),alertView(): 是错误的。就像我说的,没有() 用于声明。此外,您没有前一种方法的结束大括号,[alert show]; 之后应该有一个}。
您没有在错误 (showAlert) 之前关闭方法的大括号。
【讨论】:
您缺少用于 showAlert() 的终止花括号。
【讨论】:
-(void) showAlert {
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
}
【讨论】: