下面是操作和警报视图。当用户点击按钮时为什么不能工作?遇到问题将“呼叫”按钮添加到iOS应用程序
警报/动作
-(IBAction)myButton
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"" message:@"Call (804) 378-7120?"
delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES",nil];
[alert show];
[alert release];
}
做什么用的用户输入
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==1)
{
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel://(804) 378-7120"]];
}
else
{
//Do whatever you want
}
}
您的类是否在头中声明了'UIAlertViewDelegate'? –