小编Meh*_*tri的帖子

在Objective c中将NSData转换为NSString

我想将NSData转换为NSString ..这是最好的方法吗?

我正在使用此代码,但最后一个字符串返回null

NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@",str);
Run Code Online (Sandbox Code Playgroud)

当我看到控制台它将打印null.

iphone objective-c ipad ios

83
推荐指数
5
解决办法
14万
查看次数

从UIImage获取Exif数据 - UIImagePickerController

我们如何从UIImagePickerController中选择UIImage获取Exif信息?

我为此做了很多研发并获得了很多回复,但仍未能实现这一点.

我已经完成了这个这个链接

请帮我解决这个问题.

提前致谢..

iphone exif objective-c ipad

53
推荐指数
4
解决办法
5万
查看次数

UIQueuingScrollView中的断言失败didScrollWithAnimation:force:

我有一个UIPageViewController设置寻呼我的ImageViewController.

ImageViewController包含UIScrollView有一个UIImageView内部.没有其他的.

我正在测试我的数据源中的3个"项目" UIPageViewController(即三页).

这一切都很好,我可以滚动和缩放,然后页面约30秒,然后我突然得到这个警告......

*** Assertion failure in -[_UIQueuingScrollView _didScrollWithAnimation:force:], /SourceCache/UIKit/UIKit-2372/_UIQueuingScrollView.m:778
Run Code Online (Sandbox Code Playgroud)

我不知道从哪里开始调试它,因为它没有指向我的任何代码,并且堆栈中没有任何代码或任何东西.

有人可以给我一个指针,指出从哪里开始调试这个.

编辑

我做了一些测试.如果scrollView正在减速(即在轻弹之后)似乎会发生,然后我尝试将PageViewController转换到另一个ViewController,因为scrollview仍在移动.

该应用程序在转换到下一页的过程中崩溃了大约20%.

编辑2

错误似乎停在了_cache_getImp行(不确定这是大写字母i还是小写字母L).

编辑3

这变得更好.我刚刚下载了Apple的PhotoScroller示例应用程序,看看他们是否以不同的方式解决了问题.嗯,不,他们没有.示例应用程序以与我的方式完全相同的方式崩溃!你必须同时缩放,滚动和转换页面,以使其更容易崩溃,但它也可能发生在它自己也可能需要更长时间才能发生.

iphone ios uipageviewcontroller

31
推荐指数
2
解决办法
6849
查看次数

纹理坐标Cocos3d

这是我如何将纹理放在我的对象上:

_obj = (CC3MeshNode *)[_world getNodeNamed:@"s0"];
_obj.material.texture = [CC3Texture textureFromFile:@"objTextureLayout.png"];
Run Code Online (Sandbox Code Playgroud)

我的对象是从3DMAX加载的,我不明白为什么我的纹理坐标(来自3DMax)丢失了...

另一个问题,我不明白为什么我的法线被翻转在一个简单的多边形上.我有什么可以忘记的?

有什么建议吗?我可以发布一些屏幕截图甚至是带有纹理的模型,以便最好地理解任何可以帮助我的人.

iphone textures objective-c cocos2d-iphone cocos3d

26
推荐指数
0
解决办法
1986
查看次数

使用批量请求在Facebook上上传多张照片

我参考以下链接完成了以下代码,以创建在Facebook上传多张照片的批量请求.

我有一些解决方案可以通过这个Facebook图形API在Facebook上传多张照片.

码:

    NSString *jsonRequest1 = @"{ \"method\": \"POST\", \"relative_url\": \"me/photos\" , \"body\": \"Hello 1\", \"attached_files\": \"file1\" }";
    NSString *jsonRequest2 = @"{ \"method\": \"POST\", \"relative_url\": \"me/photos\" , \"body\": \"Hello 2\", \"attached_files\": \"file2\" }";
    NSString *jsonRequestsArray = [NSString stringWithFormat:@"[ %@, %@ ]", jsonRequest1, jsonRequest2];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:jsonRequestsArray,@"batch",nil];
    [params setObject:UIImagePNGRepresentation(self.image1) forKey:@"file1"];
    [params setObject:UIImagePNGRepresentation(self.image2) forKey:@"file2"];
    [objFacebook requestWithGraphPath:@"me" andParams:params andHttpMethod:@"POST" andDelegate:self];
Run Code Online (Sandbox Code Playgroud)

现在,当我运行此代码时,我得到以下输出.

结果词典 - (void)request:(FBRequest *)request didLoad:(id)result

(
        {
        body = "{\"error\":0,\"error_description\":\"File file1 has not been attached\"}"; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ipad facebook-graph-api

25
推荐指数
1
解决办法
3282
查看次数

在+ UIDocumentInteractionController中打开:如何过滤iOS iOS 6中的选项(不推荐使用canPerformActions)

由于新的SDK是释放(iOS 6中),委托方法documentInteractionController:canPerformAction:UIDocumentInteractionControllerDelegate已弃用.

使用该方法,你能阻止默认操作,如print:copy:出现.

该方法在当前版本的iOS 6中调用,但在将来的版本中,此方法将不会被调用,我的应用程序将显示我不想支持的操作.

我阅读了UIDocumentInteractionController及其委托的可用文档,我无法找到另一种方法来执行我在canPerformAction方法中所做的工作.

有任何想法吗?

作为一个加号,能够过滤邮件或推特等应用程序(默认情况下显示)会很棒,但我想这是不可能的.

iphone ipad ios uidocumentinteraction ios6

16
推荐指数
2
解决办法
9996
查看次数

为iOS编译pHash

如何编译pHash iOS

我阅读文档,但没有提及iOS/armGoogle没有帮助.

因此,如果有人能够为iOS编译pHash,请分享您的经验.

iphone arm objective-c ios phash

13
推荐指数
1
解决办法
1218
查看次数

iPhone:使用FPPopover类与UIBarButtonItem一起使用时出错

我正在使用FPPopover类为iPhones创建弹出窗口.我按照自述文件中的确切步骤,但不是使用xib文件中的UI按钮,而是使用以编程方式创建的UIBarButtonItem.但是,我收到以下错误:

因未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [UIBarButtonItem superview]:无法识别的选择器发送到实例0x6a3e420'

我复制粘贴了自述文件中的相同代码,但我刚刚用(id)发送者更改了(UIButton*)okButton(这里的ID是UIBarButtonItem*)

-(void)popover:(id)sender
{
    //the view controller you want to present as popover
    TestClass *controller = [[TestClass alloc] init];
    //our popover
    FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller];
    //the popover will be presented from the okButton view
    [popover presentPopoverFromView:sender];
    //release
    [controller release];
}
Run Code Online (Sandbox Code Playgroud)

我想也许它与UIBarButtonItem有关,它不是UIButton?还是别的什么?我尝试将UIBarButtonItem转换为UIButton,但仍然给了我同样的错误.有什么解决方案吗?

还有一点需要注意:这是我以编程方式创建导航栏和条形按钮的方式:

UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(320, 0, 320, 44)];
UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"By Clubs"];
[navBar pushNavigationItem:navItem animated:NO];
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Filter"
                                               style:UIBarButtonItemStyleBordered
                                              target:self
                                              action:@selector(popover:)];


navItem.rightBarButtonItem = …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios

13
推荐指数
1
解决办法
2123
查看次数

如何从iPhone框架创建视频

我已经完成了研发工作并取得了成功,如何根据播放的视频文件中的图像获取帧MPMoviePlayerController.

从此代码中获取所有帧,并将所有图像保存在一个阵列中.

for(int i= 1; i <= moviePlayerController.duration; i++)
{
    UIImage *img = [moviePlayerController thumbnailImageAtTime:i timeOption:MPMovieTimeOptionNearestKeyFrame];
    [arrImages addObject:img];
}
Run Code Online (Sandbox Code Playgroud)

现在的问题是,在更改了一些图像文件后,比如为图像添加情感并添加过滤器,例如; 电影真实,黑白,我们如何再次创建视频并以相同的帧速率将相同的视频存储在文档目录中,而不会丢失视频质量.

更改了一些图像后,我按照代码再次保存了该视频.

- (void) writeImagesAsMovie:(NSString*)path 
{
    NSError *error  = nil;
    UIImage *first = [arrImages objectAtIndex:0];
    CGSize frameSize = first.size;
    AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:
                                  [NSURL fileURLWithPath:path] fileType:AVFileTypeQuickTimeMovie
                                                              error:&error];
    NSParameterAssert(videoWriter);

    NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                   AVVideoCodecH264, AVVideoCodecKey,
                                   [NSNumber numberWithInt:640], AVVideoWidthKey,
                                   [NSNumber numberWithInt:480], AVVideoHeightKey,
                                   nil];
    AVAssetWriterInput* writerInput = [[AVAssetWriterInput
                                        assetWriterInputWithMediaType:AVMediaTypeVideo
                                        outputSettings:videoSettings] retain];

    AVAssetWriterInputPixelBufferAdaptor *adaptor = [AVAssetWriterInputPixelBufferAdaptor
                                                     assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput
                                                     sourcePixelBufferAttributes:nil];

    NSParameterAssert(writerInput); …
Run Code Online (Sandbox Code Playgroud)

video objective-c mpmovieplayercontroller avfoundation

12
推荐指数
1
解决办法
1万
查看次数

擦除UIImageView

如何通过在手指上滑动来擦除前面UIImage上的内容并显示UIView背面的UIImage.

我曾使用以下代码- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 擦除前图像:

-(void)eraseDrawingContents
{
    UIGraphicsBeginImageContext(frontImage.frame.size);
    [frontImage.image drawInRect:CGRectMake(0, 0, frontImage.frame.size.width, frontImage.frame.size.height)];

    CGContextSaveGState(UIGraphicsGetCurrentContext());
    CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES);
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 25.0);
    CGContextSetShadowWithColor(UIGraphicsGetCurrentContext(), CGSizeMake(0, 0), 50, [[UIColor whiteColor]CGColor]);

    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, nil, lastPoint.x, lastPoint.y);
    CGPathAddLineToPoint(path, nil, currentPoint.x, currentPoint.y);
    CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear);
    CGContextAddPath(UIGraphicsGetCurrentContext(), path);
    CGContextStrokePath(UIGraphicsGetCurrentContext());

    frontImage.image = UIGraphicsGetImageFromCurrentImageContext();
    CGContextRestoreGState(UIGraphicsGetCurrentContext());
    UIGraphicsEndImageContext();

    lastPoint = currentPoint;
}
Run Code Online (Sandbox Code Playgroud)

我实现了以下输出.

在此输入图像描述

但我需要像这样的输出.

在此输入图像描述

我们如何实现这一功能?

请帮我.

iphone objective-c uiimageview cgcontext ios

12
推荐指数
2
解决办法
3068
查看次数