【发布时间】:2012-10-12 12:24:46
【问题描述】:
我正在开发一个应用程序,我有一个要求,即当有来电时调用相应的方法。我编写了alertview代码,它可以完美运行并显示alertview。
Alertview 包含两个按钮接受和拒绝,当我单击这些按钮中的任何一个时,不会调用 alertview 委托方法。
+ (void)incomingCallAlertView:(NSString *)string
{
UIAlertView *callAlertView=[[UIAlertView alloc] initWithTitle:string message:@"" delegate:self cancelButtonTitle:@"reject" otherButtonTitles:@"accept",nil];
[callAlertView show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"clickedButtonAtIndex");
if(buttonIndex==0)
{
NSLog(@"buttonindex 0");
}
else
{
NSLog(@"buttonindex 1");
}
}
我正在使用主线程从另一个方法调用+(void)incomingcall 方法。
- (void)showIncomingcalling
{
[CallingViewController performSelectorOnMainThread:@selector(incomingCallAlertView:) withObject:@"on_incoming_call" waitUntilDone:YES];
}
我在课堂上编写协议,即<UIAlertViewDelegate>,但没有调用委托方法,任何人都可以解决我的问题提前谢谢。
【问题讨论】:
标签: ios iphone objective-c uialertview