You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native中AR QuickLook分享按钮禁用/功能修改方法咨询

Can I Disable or Modify AR QuickLook's Built-in Model Share Button?

Yes, you can customize or remove the share button in AR QuickLook by modifying the native iOS code wrapped by react-native-file-viewer. Here's how to do it:

Disable the Share Button Completely

  1. Open node_modules/react-native-file-viewer/ios/RNFileViewerManager.m
  2. Update the class interface to include the QLPreviewControllerDelegate protocol:
    @interface RNFileViewerManager () <QLPreviewControllerDelegate>
    
  3. When initializing the QLPreviewController, set its delegate to self:
    QLPreviewController *previewController = [[QLPreviewController alloc] init];
    previewController.delegate = self; // Add this line
    previewController.dataSource = self;
    
  4. Add the following delegate method to override the navigation item and remove the share button:
    - (UINavigationItem *)previewController:(QLPreviewController *)controller navigationItemForPreviewItem:(id<QLPreviewItem>)previewItem {
        UINavigationItem *navItem = controller.navigationItem;
        navItem.rightBarButtonItems = nil; // Clear the default share button
        return navItem;
    }
    

Replace with Custom Share Functionality

If you want to keep a share button but change what it does (e.g., share a link instead of the full model file):

  1. Use the same delegate method to replace the default button with a custom one:
    - (UINavigationItem *)previewController:(QLPreviewController *)controller navigationItemForPreviewItem:(id<QLPreviewItem>)previewItem {
        UINavigationItem *navItem = controller.navigationItem;
        
        // Create a custom action button
        UIBarButtonItem *customShareBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction 
                                                                                         target:self 
                                                                                         action:@selector(triggerCustomShare:)];
        navItem.rightBarButtonItems = @[customShareBtn];
        
        return navItem;
    }
    
  2. Add the custom share handler method:
    - (void)triggerCustomShare:(UIBarButtonItem *)sender {
        // Example: Share a URL instead of the model file
        NSString *shareContent = @"https://your-app.com/model-viewer";
        UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[shareContent] 
                                                                                       applicationActivities:nil];
        
        // Get the top view controller to present the share sheet
        UIViewController *topVC = [UIApplication sharedApplication].keyWindow.rootViewController;
        while (topVC.presentedViewController) {
            topVC = topVC.presentedViewController;
        }
        [topVC presentViewController:activityVC animated:YES completion:nil];
    }
    

Keep Changes Persistent

Modifying node_modules directly will lose your changes when you run npm install or yarn install. Use patch-package to save your edits as a patch:

  1. Install the package: npm install patch-package --save-dev
  2. After making your changes, run: npx patch-package react-native-file-viewer
  3. A patch file will be created in the patches/ directory. It will automatically apply on future dependency installs.

Note: The canonical website approach you attempted is designed to let AR QuickLook share a link to your model instead of the raw file, but it doesn't disable the share button itself. That's why it didn't solve your problem.

内容的提问来源于stack exchange,提问作者Arima132

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 12:40:24