0

私はiosとPNSを初めて使用します。これに基づいて通知でURLを取得するプッシュ通知に取り組んでおり、画像を画像ビューに表示する必要があります。PNSを正常に取得し、ペイロードを使用してURLも取得しましたが、別のクラスの画像ビューに表示されません以下は私が使用しているコードです

  - (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
if (application.applicationState == UIApplicationStateActive) // If app is running and you got notification then show it 
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Did receive a Remote Notification" message:[NSString stringWithFormat:@"You Have a Notification :\n%@",userInfo[@"aps"][@"alert"]]delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [alertView show];
}
NSLog(@"Payload: %@", userInfo);
imageURL =  userInfo[@"aps"][@"alert"];
MainViewController *mv =  [[MainViewController alloc] init];
[mv.ansinage setImage:[UIImage imageNamed:@"cartoon.png"]]; // Right now i am setting image in resource but still not setting in mainviewcontrller when i am open app

}
4

1 に答える 1

0
-(void) sshowansimage:(NSString *) strImageURL{

NSURL *imageURL = [NSURL URLWithString:strImageURL];
NSLog(@"coming URL is %@", strImageURL);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
    NSData *imageData = [NSData dataWithContentsOfFile:strImageURL];
    [self performSelectorOnMainThread:@selector(showImage:) withObject:imageData waitUntilDone:YES];
});

}

-(void)showImage:(NSData*)imageAsData
{
NSLog(@"IN image view mthhod data is %d",imageAsData.length);
ansinage.image = [UIImage imageWithData:imageAsData];

}
于 2013-11-18T09:05:42.637 に答える