UIActivityViewController issue iOS 7 and iOS 8?

后端 未结 3 858
自闭症患者
自闭症患者 2021-02-15 01:36

I’m building an article reading app for iPad. I have integrated a social sharing functionality which means user can share articles on Facebook, and google mail. I’m using

3条回答
  •  心在旅途
    2021-02-15 02:21

    Following line is the issue

    AVC.popoverPresentationController.sourceView = _webView;
    

    You will have to put iOS8 condition in order popoverPresentationController is introduced for iOS 8 and later so you can not use it with iOS 7

    For checking for iOS8 you can define a macro like found from here

    #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
    

    And use it in following way.

         NSURL *linkURL = [NSURL URLWithString:_DetailModal1[4]];//article url
         NSMutableAttributedString *stringText = [[NSMutableAttributedString alloc]  initWithString:_DetailModal1[0]];//_DetailModal1[0] contain article title////
        [stringText addAttribute:NSLinkAttributeName value:linkURL range:NSMakeRange(0, stringText.length)];
        NSArray * itemsArray = @[[NSString stringWithFormat:@"%@",_DetailModal1[0]], [NSURL URLWithString:_DetailModal1[4]]];
        NSArray * applicationActivities = nil;
        UIActivityViewController * AVC = [[UIActivityViewController alloc] initWithActivityItems:itemsArray applicationActivities:applicationActivities];
    
       if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")){
    
            AVC.popoverPresentationController.sourceView = _webView;
       }
       [self presentViewController:AVC animated:YES completion:nil];
    

    Refer this for more info about what has changed for UIActivityViewController in iOS8

提交回复
热议问题