OGeek|极客世界-中国程序员成长平台

标题: ios - 在菜单 View 中排序项目后丢失的项目 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 13:38
标题: ios - 在菜单 View 中排序项目后丢失的项目

UIActivity 函数有问题。

首先,我创建了3个事件项:

  1. activityDownload
  2. activityTrash
  3. activityMove.

并添加到 UIActivityViewController 然后,当我展示包含上述 3 项的 UIActivityViewController 时。好的,这里没问题。 然后,当我单击“更多”按钮并对项目进行排序时,例如,我将“移动”按钮移到顶部, 单击“完成”按钮后,我不知道为什么下载,垃圾邮件丢失了? 移动项目仅显示在 AirDrop 菜单 View 中。

NSURL *url = [self fileToURL:self.documentName];
NSArray *objectsToShare = @[url];

AirDropActivityView *activityDownload = [[AirDropActivityView alloc] init];
activityDownload.airDropType = 0;
AirDropActivityView *activityTrash = [[AirDropActivityView alloc] init];
activityTrash.airDropType = 1;
AirDropActivityView *activityMove = [[AirDropActivityView alloc] init];
activityMove.airDropType = 2;

NSArray *uiActivitys = @[activityDownload,activityTrash,activityMove];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItemsbjectsToShare applicationActivities:uiActivitys];

// Exclude all activities except AirDrop.
NSArray *excludedActivities = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook, UIActivityTypePostToWeibo,UIActivityTypeMessage,UIActivityTypePrint, UIActivityTypeCopyToPasteboard UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll,UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,UIActivityTypePostToVimeo,UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludedActivities;

// Present the controller
[self presentViewController:controller animated:YES completion:nil];

https://gist.github.com/tranhieutt/f73999234339f31aa86c

请看截图:

enter image description here

enter image description here



Best Answer-推荐答案


这可能是您使用的所有自定义 UIActivity View 具有相同的 activityType 会导致此问题。

所以我建议为您要使用的每个 View 创建更多的自定义 UIActivity。像这样:

创建AirDropActivityView1; 在AirDropActivityView1.m中,实现:

#import "AirDropActivityView1.h"

@implementation AirDropActivityView

- (NSString *)activityType
{
    return @"youapp.Activity1";
}

- (NSString *)activityTitle
{
    return @"Activity1";
}

- (BOOL)canPerformWithActivityItemsNSArray *)activityItems
{
    return YES;
}

@end

AirDropActivityView2.m

    #import "AirDropActivityView2.h"

    @implementation AirDropActivityView

    - (NSString *)activityType
    {
        return @"youapp.Activity2";
    }

    - (NSString *)activityTitle
    {
        return @"Activity2";
    }

    - (BOOL)canPerformWithActivityItemsNSArray *)activityItems
    {
        return YES;
    }

    @end

最后:

    AirDropActivityView1 *activity1 = [[AirDropActivityView1 alloc] init];

    AirDropActivityView2 *activity2 = [[AirDropActivityView2 alloc] init];

    NSArray *uiActivitys = @[activity1,activity2];

现在您可以重新排序。 希望对您有所帮助。

关于ios - 在菜单 View 中排序项目后丢失的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34894040/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) Powered by Discuz! X3.4