使用UIActivityViewController添加到iCloud Drive

时间:2016-09-28 19:15:48

标签: ios objective-c uiactivityviewcontroller uiactivity uiactivityitemprovider

我想使用UIActivityViewController"添加到iCloud Drive"这里描绘的动作是上传我存储在iOS设备上的文件:

enter image description here

目前在我的自定义UIActivityItemProvider类中,我有 - (id)item方法返回:         [NSURL fileURLWithPath:fullPath];

FullPath是我正在创建并希望上传到iCloud驱动器的文件的路径。当我单击"添加到Notes",邮件活动或我的自定义活动但它不适用于iCloud驱动器时,它可以正常工作。它不是使用这个文件,而是创建一个默认文件,其中包含我用于电子邮件活动的主题,即"附加的是文件。"作为文件内容。这是我用来呈现UIActivityViewController的代码:

(%i5) is(equal( (a+b)^2, a^2+b^2+2*a*b )) $
                            2   2    2
1 Enter is [is(equal((a + b) , a  + b  + 2 a b))]
 1 Enter ratp [2]
 1 Exit  ratp false
 1 Enter ratp [b + a]
 1 Exit  ratp false
 1 Enter ratp [2]
 1 Exit  ratp false
 1 Enter ratp [b + a]
 1 Exit  ratp false
 1 Enter ratp [2]
 1 Exit  ratp false
 1 Enter ratp [a]
 1 Exit  ratp false
 1 Enter ratp [2]
 1 Exit  ratp false
 1 Enter ratp [b]
 1 Exit  ratp false
                      2
 1 Enter setp [(b + a) ]
 1 Exit  setp false
                   2            2
 1 Enter subvarp [b  + 2 a b + a ]
 1 Exit  subvarp false
                   2            2
 1 Enter subvarp [b  + 2 a b + a ]
 1 Exit  subvarp false
                         2    2            2
 1 Enter ratsimp [(b + a)  - b  - 2 a b - a ]
                       2    2            2
  1 Enter ratp [(b + a)  - b  - 2 a b - a ]
  1 Exit  ratp false
                              2    2            2
  1 Enter totaldisrep [(b + a)  - b  - 2 a b - a ]
                             2    2            2
  1 Exit  totaldisrep (b + a)  - b  - 2 a b - a
  1 Enter ratdisrep [0]
   1 Enter ratp [0]
   1 Exit  ratp true
  1 Exit  ratdisrep 0
 1 Exit  ratsimp 0
 1 Enter facts []
 1 Exit  facts []
 1 Enter niceindices [0]
 1 Exit  niceindices 0
 1 Enter constantp [0]
  1 Enter numberp [0]
   1 Enter ratnump [0]
   1 Exit  ratnump true
  1 Exit  numberp true
 1 Exit  constantp true
 1 Enter rectform [0]
 1 Exit  rectform 0
 1 Enter sign [0]
 1 Exit  sign zero
1 Exit  is true
1 Enter concat [, %o, 5]
1 Exit  concat %o5
1 Enter concat [, %i, 5]
1 Exit  concat %i5
1 Enter concat [, %i, 6]
1 Exit  concat %i6

1 个答案:

答案 0 :(得分:1)

代码似乎是正确的。但是只有在以下情况下才会添加iCloud选项:

  
      
  1. 用户必须在“设置”中登录iCloud。

  2.   
  3. 您可以在iCloud上上传一些有效的信息。 (如果您在共享中使用任何URL,则ActivityController中不会显示iCloud选项)

  4.   

它支持您可以上传的那些类型的数据,如笔记,照片,联系人,日历活动等。

我试过这个:

NSString *strTextToShare = @"Hi... Friends";
UIImage *imgToShare = [UIImage imageNamed:@"wall1.png"];
NSURL *urlToShare = [NSURL URLWithString:@"https://www.apple.com"];

UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:@[strTextToShare, /*imgToShare, urlToShare*/] applicationActivities:nil];
[self presentViewController:shareController animated: YES completion: nil];

在上面,如果我尝试添加URL,则iCloud未显示。而且

  

注意:如果您只分享一个项目,那么只显示iCloud。