【问题标题】:Is a custom UIActivity with the bookmark icon possible?是否可以使用带有书签图标的自定义 UIActivity?
【发布时间】:2014-11-28 01:01:26
【问题描述】:

我的 iOS 应用程序的一部分是带有 UIActivityViewController 的文件查看器。从中,我希望用户能够对文件进行正常的活动视图操作,例如邮寄、将其保存到照片(如果是照片)以及其他所有内容。但是,我的应用程序具有书签功能。我希望用户能够从此菜单中为文件添加书签。我创建了一个自定义 UIActivity 来将该对象添加到书签列表中,但我无法弄清楚如何让它使用系统书签图标。这甚至可能吗?

编辑:为澄清起见,这是在您单击“共享”按钮时出现的菜单中。

【问题讨论】:

    标签: ios user-interface uiactivityviewcontroller


    【解决方案1】:

    简单易懂。这一切都取决于您如何启动它,是在导航控制器、滑动手势、工具栏项还是只是一个常规按钮?无论哪种方式都没有关系,但如果你想要一个具体的答案,你必须提出一个具体的问题。

    这是一个示例,如何使用连接在 Storyboard 界面中的书签按钮完成您的目标购买,但是 addToFav 和下载的 IBActions 不是界面,不需要:

    -(IBAction) moreActions:(id)sender {
    UIActionSheet *moreActions = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Add To Favorites", @"Download For Offline View",@"Open Document In :", nil];
    [moreActions showInView:self.view];
    }
    

    您执行操作的方式是调用以下方法:

    -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    
    switch (buttonIndex) {
        case 0: [self addToFav:self]; //See IBAction below
            break;
        case 1: [self download:self]; //See IBAction below
            break;
        case 2: {
            //UIDocumentInteractionController:
    
            NSURL *docURL = [NSURL URLWithString:@"filePathStringHere"];
    
            documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:docURL];
            [documentInteractionController setDelegate:self];
            [documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
        }
            break;
    }
    

    }

     - (IBAction)download:(id)sender {
    //enter your download code here
    }
    
    - (IBAction)addToFav:(id)sender {
    //Code to add to your favorites
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-03
      • 1970-01-01
      • 2018-01-30
      • 1970-01-01
      • 2014-02-22
      • 2017-07-03
      相关资源
      最近更新 更多