2

I am writing the iOS app in objective C code and this is the method for action when user taps on a button on the barItem

- (void)tappedInToolbar:(MyToolbar *)toolbar shareButton:(UIButton *)button {
   
     UIActivityViewController *activityController = [[UIActivityViewController alloc]
                                      initWithActivityItems:@[self, document.fileURL] 
                                      applicationActivities:nil];
      
     activityController.modalPresentationStyle = UIModalPresentationPopover;
    
     [self presentViewController:activityController animated:YES completion:nil];
    
     UIPopoverPresentationController *popController = [activityController popoverPresentationController];
      
     popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
      
     popController.sourceView = button;
     
 }

The app is able to present the Activity Controller successfully and I can select many system apps to share my files such as 'Airdrop' Mail, Notes etc; However whenever I tap on the Messages to share the files the app will crash with this stack trace.

If anyone know how to fix this problem please share, it would be really appreciated.

1   
IOSurface
IOSurfaceClientGetPixelFormat + 0
2   
QuartzCore
CA::CG::IOSurfaceContext::create_delegate(CGIOSurfaceContextInfo const*, __CFDictionary const*) + 544
3   
CoreGraphics
CGIOSurfaceContextCreate + 212
4   
BaseBoardUI
BSUISurfaceWithColorSpaceAndDrawBlock + 536
5   
SpringBoardFoundation
SBFCreateIOSurfaceForImage + 1092
6   
ChatKit
-[CKRemoteItemForSending _setPreviewUIImage:] + 80
7   
ChatKit
__46-[CKRemoteItemForSending beginPreviewCreation]_block_invoke + 208
8   
Foundation
__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 20
9   
Foundation
-[NSBlockOperation main] + 100
10  
Foundation
__NSOPERATION_IS_INVOKING_MAIN__ + 20
11  
Foundation
-[NSOperation start] + 736
12  
Foundation
__NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 20
13  
Foundation
__NSOQSchedule_f + 180
14  
libdispatch.dylib
_dispatch_block_async_invoke2 + 140
15  
libdispatch.dylib
_dispatch_client_callout + 16
greg-449
  • 109,219
  • 232
  • 102
  • 145
Ohmy
  • 2,201
  • 21
  • 24
  • @matt thanks for the comment, having self or not does not make a different. I removed it and it still crashes. – Ohmy Aug 14 '20 at 20:31
  • I cannot reproduce it. Does it happen on particular iOS version? Does it happen only on particular device? Is `UIPopoverPresentationController *popController` necessary for the crash to occur? Can you share a minimal sample project that can replicate this? – Kamil.S Sep 22 '20 at 18:08
  • Why do you put `self` to your `initWithActivityItems`? Do you support `UIActivityItemSource` in your view controller? If not you should remove it. – iUrii Sep 23 '20 at 10:13
  • You use ```UIButton``` but from the text I'd expect it to be ```UIBarButtonItem```? Just to confirm you are presenting from a UIButton or UIBarButtonItem? – skaak Sep 23 '20 at 14:00

0 Answers0