我正在制作用于在iOS中创建登机牌的存折功能,我可以创建一个登机牌并且运行良好,但是在创建多个传票时,我遇到了以下问题:
我可以获得计数,但所有通行证都被替换为最后一次审核
选择SAVE ALL后,存折应用程序中只有一个传递,即最后一个传递。
我使用以下代码来显示通行证
-(void) initializeWithMultiPassbookArray:(NSMutableArray *)arrPasses
{
NSMutableArray *arrPKPass = [[NSMutableArray alloc] init];
for(NSString *path in arrPasses)
{
NSData *data;
if(path && path.length)
{
data = [[NSData alloc] initWithContentsOfFile:path];
NSError *error;
PKPass *passSample = [[PKPass alloc] initWithData:data error:&error];
if(passSample)
{
[arrPKPass addObject:passSample];
passSample = nil;
}
else
JALog(@"passSample is nil");
}
else
{
JALog(@"Error occured while fetching pkpass data from cache path");
}
}
if(arrPKPass && arrPKPass.count > 1)
{
if(!self.passLibrary)
self.passLibrary = [[PKPassLibrary alloc] init];
__weak BookingSuccessfulViewController *self_ = self;
if(viewPopUpBg)
{
[viewPopUpBg removeFromSuperview];
viewPopUpBg = nil;
}
[self.passLibrary addPasses:arrPKPass withCompletionHandler:^(PKPassLibraryAddPassesStatus status) {
switch (status) {
case PKPassLibraryDidAddPasses:
{
[App_Delegate performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];
if([self_ respondsToSelector:@selector(showAlertFor:withMsg:withTag:)])
[self_ showAlertFor:SAVED withMsg:@"Your booking details have been added to Passbook." withTag:0];
break;
}
case PKPassLibraryDidCancelAddPasses:
{
[App_Delegate performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];
break;
}
case PKPassLibraryShouldReviewPasses:
{
//[self_ performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];
[App_Delegate performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];
PKAddPassesViewController *vcPKAddPass = [[PKAddPassesViewController alloc] initWithPasses:arrPKPass];
[vcPKAddPass setDelegate:(id)self_];
[self_ presentViewController:vcPKAddPass animated:YES completion:nil];
vcPKAddPass = nil;
break;
}
default:
break;
}
}];
}
else if(arrPKPass.count == 1)
{
if(viewPopUpBg)
{
[viewPopUpBg removeFromSuperview];
viewPopUpBg = nil;
}
[App_Delegate performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];
PKPass *passLocal = [arrPKPass objectAtIndex:0];
if(passLocal)
{
self.currentPass = passLocal;
//present view controller to add the pass to the library
PKAddPassesViewController *vcPKAddPass = [[PKAddPassesViewController alloc] initWithPass:passLocal];
[vcPKAddPass setDelegate:(id)self];
[self presentViewController:vcPKAddPass animated:YES completion:nil];
vcPKAddPass = nil;
}
}
else
{
JALog(@"arrPKPass is nil");
}
}
答案 0 :(得分:0)
得到了我的答案:
每个通行证应在键中包含不同的序列号" serialNumber"在创建JSON时
同时检查项目中的功能>目标>功能> Passbook
使用特定标识符选择允许传递类型的子集。
这些步骤对我有用。
希望也能帮助别人。
由于