下面是操作和警報視圖。當用戶點擊按鈕時爲什麼不能工作?遇到問題將「呼叫」按鈕添加到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'? –