【发布时间】:2015-01-18 12:20:45
【问题描述】:
当我收到推送通知时,我会在 appDelegate 中调用此方法
-(void)activeNotification:(NSDictionary *)userInfo{
NSLog(@"%@",userInfo);
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
ViewController *view=[[ViewController alloc]init];
[view checkNotification:message];
}
从这里调用 ViewController.m 中定义的方法checkNotification:message()
-(void)checkNotification:(NSString *)message{
NSLog(@"%@",message);
NSArray *arr=[[NSArray alloc]init];
if([message hasPrefix:@"taxi"])
{
arr=[message componentsSeparatedByString:@":"];
alertV=[[UIAlertView alloc]initWithTitle:@"Taxi" message:[arr objectAtIndex:1] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertV show];
}
}
当我点击确定按钮时,我需要调用 alertview 委托方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
}
但是这个方法没有被调用,请帮助我
在我的 ViewController.h 中
@interface ViewController : UIViewController<FBLoginViewDelegate,UIAlertViewDelegate>
我不知道为什么不调用 AlertView 委托..
【问题讨论】:
-
在您的应用委托中,您正在分配一个新的视图控制器实例。您可能希望在屏幕上已经存在的实例上调用该方法
-
请告诉我清楚..我什么都不懂
-
我可以在我的应用程序屏幕上看到 alertview 唯一的问题是当我单击“确定”按钮时,委托方法不起作用
-
当你说 ` ViewController *view=[[ViewController alloc]init];` 你正在创建一个新的 ViewController 实例 - 这不是管理你的显示的实例
-
那么我该如何调用我的方法呢?
标签: ios objective-c delegates uialertview