2016-07-22 122 views
-1

我一直在打碼時得到popovercontroller錯誤,這裏是我的代碼:我不斷收到一個錯誤

- (IBAction)sharePost:(id)sender { 
    NSArray *activityItems; 
    NSInteger tid = ((UIControl *) sender).tag; 

    if ([catName isEqualToString:@"All"]) 
    { 
     //UIImage *snapshotImage = [self imageFromView:self.view]; 
     activityItems = @[[self.titleArray objectAtIndex:tid],[self.linkArray objectAtIndex:tid],[self.imageArray objectAtIndex:tid]]; 
    } 
    else 
    { 
     activityItems = @[[self.titleCatArray objectAtIndex:tid],[self.linkCatArray objectAtIndex:tid],[self.imageCatArray objectAtIndex:tid]]; 
    } 

    UIActivityViewController *activityController = 

    [[UIActivityViewController alloc] 

    initWithActivityItems:activityItems 

    applicationActivities:nil]; 

    [self presentViewController:activityController   
         animated:YES completion:nil];   
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

我想要得到它的工作在iPad上,我有在網上看了一切,但無法弄清楚。

回答

0

在文檔UIActivityViewController:

在iPad上,你必須在酥料餅呈現視圖控制器。在iPhone和iPod touch上,您必須以模態形式呈現它。

嘗試:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:activityController]; 
    [popover presentPopoverFromRect:[sender bounds] 
          inView:sender   
      permittedArrowDirections:UIPopoverArrowDirectionAny   
          animated:YES]; 
    self.popover = popover; 
} else { 
    [self presentViewController:activityController 
         animated:YES 
        completion:nil]; 
} 
+0

現在快到了警告: –

+0

警告:加入後使用didReceiveMemoryWarning未聲明的標識符的這個 –

+0

你有一個'}'爲sharePost的'結束:'在'}'結束'else'子句之後? – Mats

相關問題