-(void)addPassbookView:(NSData *)date{

NSError *error = nil;

BOOL passEnbale = [PKPassLibrary isPassLibraryAvailable];//检查pass是否可用

if (![PKPassLibrary isPassLibraryAvailable]) {//

dispatch_async(dispatch_get_main_queue(), ^{

//[[WaitDialogFullS sharedWaitDialog] endLoading];

[[[UIAlertView alloc] initWithTitle:@"Error"

message:@"PassKit not available"

delegate:nil

cancelButtonTitle:GDLocalizedString(@"jpyd_ok")

otherButtonTitles: nil] show];

});

return;

}

if (passEnbale) {

PKPass *onePass = [[PKPass alloc] initWithData:date error:&error];

if (error) {

dispatch_async(dispatch_get_main_queue(), ^{

// [[WaitDialogFullS sharedWaitDialog] endLoading];

ZNLog(@"!!!!!ERROR:%@",[error description]);

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:GDLocalizedString(@"jpyd_Friendlyreminder") message:GDLocalizedString(@"sy_onePass") delegate:nil cancelButtonTitle:GDLocalizedString(@"jpyd_ok") otherButtonTitles:nil, nil];

[alert show];

[alert release];

});

return ;

}

dispatch_async(dispatch_get_main_queue(), ^{

PKAddPassesViewController *passAddViewController = [[[PKAddPassesViewController alloc] initWithPass:onePass]autorelease];

passAddViewController.delegate = self;

ChinaEastViewController *app = [ChinaEastViewController sharedBankcommViewController];

//Application tried to present a nil modal view controller on target .修改听云,李良

if (passAddViewController) {

[app presentViewController:passAddViewController animated:YES completion:^{

// [[WaitDialogFullS sharedWaitDialog] endLoading];

}];

}

});

}

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐