我使用以下代码在共享容器路径下创建文件夹/文件.这将有助于应用扩展程序和包含应用程序的扩展程序可以访问数据.
获取共享容器url位置的代码:
+(NSURL*)getSharedContainerURLPath
{
NSFileManager *fm = [NSFileManager defaultManager];
NSString *appGroupName = APP_EXTENSION_GROUP_NAME; /* For example */
NSURL *groupContainerURL = [fm containerURLForSecurityApplicationGroupIdentifier:appGroupName];
return groupContainerURL;
}
Run Code Online (Sandbox Code Playgroud)
用于创建目录的代码
+(void)createDirAtSharedContainerPath
{
NSString *sharedContainerPathLocation = [[self getSharedContainerURLPath] absoluteString];
NSString *directoryToCreate = @"user_abc";
//basically this is <shared_container_file_path>/user_abc
NSString *dirPath = [sharedContainerPathLocation stringByAppendingPathComponent:directoryToCreate];
BOOL isdir;
NSError *error = nil;
NSFileManager *mgr = [[NSFileManager alloc]init];
if (![mgr fileExistsAtPath:dirPath isDirectory:&isdir]) { //create a dir only that does not exists
if (![mgr createDirectoryAtPath:dirPath withIntermediateDirectories:YES attributes:nil error:&error]) {
NSLog(@"error while …Run Code Online (Sandbox Code Playgroud) 有没有人知道如何从应用扩展程序的视图控制器启动父应用程序?
我只想从其应用扩展程序启动主应用程序.
我将Google drive sdk与我的iOS应用集成在一起.但我不知道如何将文件上传到Google驱动器特定文件夹.
这里的代码用于上传文件.但是这个上传文件到我的谷歌驱动器根文件夹.任何人共享代码将文件上传到谷歌驱动器特定文件夹?
我的代码:
-(void)uploadFileToGoogleDrive:(NSString*)fileName
{
GTLDriveFile *driveFile = [[[GTLDriveFile alloc]init] autorelease];
driveFile.mimeType = @"application/pdf";
driveFile.originalFilename = @"test.doc";
driveFile.title = @"test.doc";
NSString *filePath = [LocalFilesDetails getUserDocumentFullPathForFileName:fileName isSignedDocument:YES];
GTLUploadParameters *uploadParameters = [GTLUploadParameters
uploadParametersWithData:[NSData dataWithContentsOfFile:filePath]
MIMEType:@"application/pdf"];
GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:driveFile
uploadParameters:uploadParameters];
[self.driveService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFile *updatedFile,
NSError *error) {
if (error == nil) {
NSLog(@"\n\nfile uploaded into google drive\\<my_folder> foler");
} else {
NSLog(@"\n\nfile uplod failed google drive\\<my_folder> foler");
}
}];
}
Run Code Online (Sandbox Code Playgroud) 在我的ios应用程序中,用户可以将pdf文件作为附件发送给其他人.它正在开发pre ios 7设备.升级到ios 7后,当应用程序显示ios邮件界面时,附件丢失.
这里我用来设置mime类型的代码:
[mailComposer addAttachmentData:pdfData mimeType:@"application/octet-stream" fileName:fileName];
Run Code Online (Sandbox Code Playgroud)
上面的mime类型在pre ios 7上很有用,但是在ios 7上它没有将我的文件作为附件.所以,我改变了像这样的mime类型:
[mailComposer addAttachmentData:pdfData mimeType:@"application/pdf" fileName:fileName];
Run Code Online (Sandbox Code Playgroud)
它在ios 7和pre ios 7设备上工作正常,但问题是,在iPad上如果附加的pdf文件有单页,则它被视为内联图像而不是附件.这种情况只发生在iPad上的iPhone上就可以了.此外,如果我将该邮件发送给某个人,在收件人方面,当他们在iphone或ipad上打开该邮件时,它也会显示为内嵌图像.因为当他们点击它时它允许两个选项1.保存图像2.取消.此问题不是关于ios 7 ipad设备,这是在ios 5,ios 6,ios 6.1和ios 7下运行的所有ipad设备上发生的.任何想法如何解决它?我应该使用什么mime类型来解决它?
注意: - 有关详细信息,请查看附带的屏幕截图
-loganathan
我将google drivs sdk与我的ios应用程序集成在一起.目前我使用以下代码从我的谷歌驱动器a/c下载文件基于下载URL链接.但是当我尝试下载谷歌文档文件(其中包含mime类型的应用程序/ vnd.google-apps.document)时,谷歌驱动器库中没有下载URL链接.在那种情况下,我如何下载谷歌文档数据?我可以使用alternateLink而不是下载url链接吗?任何帮助必须得到赞赏.
我的代码:
- (void)loadFileContent {
GTMHTTPFetcher *fetcher =
[self.driveService.fetcherService fetcherWithURLString:[[self.driveFiles objectAtIndex:selectedFileIdx] downloadUrl]];
[fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error) {
if (error == nil) {
NSLog(@"\nfile %@ downloaded successfully from google drive", [[self.driveFiles objectAtIndex:selectedFileIdx] originalFilename]);
//saving the downloaded data into temporary location
} else {
NSLog(@"An error occurred: %@", error);
}
}];
Run Code Online (Sandbox Code Playgroud)
}
实际上我正在做的是在iPad上我正在呈现具有我自己尺寸(520 X 400)的模态表单.它第一次工作正常.然后,当我旋转(纵向到横向或横向到纵向)时,我的模态表单更改为ios默认大小.此外,我无法通过编程方式再次更改模态表单大小.因为,一旦方向改变了ios使我的(520X400)模态表格到其默认大小.知道怎么解决这个问题吗?


注意:
当我在ios7设备上运行时,我没有看到以下代码的任何问题.如果我的代码有任何问题,请指出我.因为我不知道ios8有什么问题
这是我用来更改模态表单大小的代码:
self.navigationController.view.superview.frame = CGRectMake(200, 220, 400, 605);
Run Code Online (Sandbox Code Playgroud) 我使用自己的ios应用程序实现了文档提供程序应用程序扩展功能.问题是应用扩展程序无法访问包含应用程序图像/资产或包含应用程序资源数据.有谁知道如何实现它?
实际上我将google drive sdk与我的ios应用程序集成在一起.我可以通过谷歌驱动器ios sdk检索/上传谷歌驱动器中的文件.但是从指定的父文件夹中检索文件列表需要花费很多时间.
这里是我正在使用的步骤和代码.
首先获取指定父文件夹的子项,然后获取每个子项的GTLDriveChildReference,然后使用子引用标识符进行查询.
这对我来说是一个巨大的过程.此外,它每次都要求谷歌服务器.有更好的方法可以在查询中传递父文件夹ID并从该父文件夹中提取文件.
-(void)getFileListFromSpecifiedParentFolder {
GTLQueryDrive *query2 = [GTLQueryDrive queryForChildrenListWithFolderId:<some_id or root>];
query2.maxResults = 1000;
// queryTicket can be used to track the status of the request.
[self.driveService executeQuery:query2
completionHandler:^(GTLServiceTicket *ticket,
GTLDriveChildList *children, NSError *error) {
NSLog(@"\nGoogle Drive: file count in the folder: %d", children.items.count);
//incase there is no files under this folder then we can avoid the fetching process
if (!children.items.count) {
return ;
}
if (error == nil) {
for (GTLDriveChildReference *child …Run Code Online (Sandbox Code Playgroud)