我想将NSData转换为NSString ..这是最好的方法吗?
我正在使用此代码,但最后一个字符串返回null
NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@",str);
Run Code Online (Sandbox Code Playgroud)
当我看到控制台它将打印null.
我们如何从UIImagePickerController中选择UIImage获取Exif信息?
我为此做了很多研发并获得了很多回复,但仍未能实现这一点.
请帮我解决这个问题.
提前致谢..
我有一个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示例应用程序,看看他们是否以不同的方式解决了问题.嗯,不,他们没有.示例应用程序以与我的方式完全相同的方式崩溃!你必须同时缩放,滚动和转换页面,以使其更容易崩溃,但它也可能发生在它自己也可能需要更长时间才能发生.
这是我如何将纹理放在我的对象上:
_obj = (CC3MeshNode *)[_world getNodeNamed:@"s0"];
_obj.material.texture = [CC3Texture textureFromFile:@"objTextureLayout.png"];
Run Code Online (Sandbox Code Playgroud)
我的对象是从3DMAX加载的,我不明白为什么我的纹理坐标(来自3DMax)丢失了...
另一个问题,我不明白为什么我的法线被翻转在一个简单的多边形上.我有什么可以忘记的?
有什么建议吗?我可以发布一些屏幕截图甚至是带有纹理的模型,以便最好地理解任何可以帮助我的人.
我参考以下链接完成了以下代码,以创建在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) 由于新的SDK是释放(iOS 6中),委托方法documentInteractionController:canPerformAction:
的UIDocumentInteractionControllerDelegate
已弃用.
使用该方法,你能阻止默认操作,如print:
和copy:
出现.
该方法在当前版本的iOS 6中调用,但在将来的版本中,此方法将不会被调用,我的应用程序将显示我不想支持的操作.
我阅读了UIDocumentInteractionController及其委托的可用文档,我无法找到另一种方法来执行我在canPerformAction方法中所做的工作.
有任何想法吗?
作为一个加号,能够过滤邮件或推特等应用程序(默认情况下显示)会很棒,但我想这是不可能的.
如何编译pHash iOS
?
我阅读文档,但没有提及iOS/arm
并Google
没有帮助.
因此,如果有人能够为iOS编译pHash,请分享您的经验.
我正在使用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) 我已经完成了研发工作并取得了成功,如何根据播放的视频文件中的图像获取帧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) 如何通过在手指上滑动来擦除前面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 ×9
objective-c ×8
ios ×6
ipad ×4
arm ×1
avfoundation ×1
cgcontext ×1
cocos3d ×1
exif ×1
ios6 ×1
phash ×1
textures ×1
uiimageview ×1
video ×1
xcode ×1