我需要将NSData从文件转换为NSString.怎么做?
首先,在LoadingVC.h中,我声明了一个协议:
@protocol VideoWorker <NSObject>
@required
@property (nonatomic) float progress;
@property (nonatomic) BOOL done;
-(void)beginWorking;
@end
@interface LoadingVC : UIViewController <UIAlertViewDelegate>
...
@end
Run Code Online (Sandbox Code Playgroud)
然后在BlurWorkerGPU.h中
...
#import "LoadingVC.h"
@interface BlurWorkerGPU : NSObject <VideoWorker> {
...
}
- (void)beginWorking;
@property(nonatomic)float progress;
@property(nonatomic)BOOL done;
...
@end
Run Code Online (Sandbox Code Playgroud)
然而,llvm说
"没有名为'VideoWorker'的类型或协议"
这很奇怪,因为我正在导入定义协议的标头.有线索吗?
我正在使用绑定到AVCaptureSession的现有AVCaptureStillImageOutput来获取静态图像.然后我需要将它们写入AVAssetWriter,最后以1秒的间隔获得填充帧的视频文件.
除了在纵向模式下输出视频尺寸外,一切正常.当设备处于横向模式时 - 一切都很好,因为captureStillImageAsynchronouslyFromConnection会生成尺寸为1920x1080(例如)的CMSampleBuffer,但是当设备处于纵向模式时,它仍会生成具有相同尺寸(1920x1080)的旋转CMSampleBuffer.我可以使用AVAssetWriterInput的.transform属性旋转最终输出视频,它工作正常,但最终视频的尺寸错误(1920x1080),但应该是1080x1920.
我发现问题出在captureStillImageAsynchronouslyFromConnection的CMSampleBuffer中,它始终具有横向尺寸.然后AVAssetWriter的输入忽略配置的宽度和高度并使用CMSampleBuffer的尺寸.
有人知道如何解决这个问题吗?
注意:我知道可以使用vImage或Core Graphics函数旋转捕获的缓冲区,但出于性能考虑,我想避免使用此方法.我的问题看起来像配置问题或iOS中的错误...
- (void) setupLongLoopWriter
{
self.currentFragment.filename2 = [VideoCapture getFilenameForNewFragment];
NSString *path = [NSString stringWithFormat:@"%@/%@", [GMConfig getVideoCapturesPath], self.currentFragment.filename2];
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(self.currentCamera.activeFormat.formatDescription);
CGSize videoWriterFrameSize = CGSizeMake(dimensions.width, dimensions.height);
float rotationAngle = 0.0;
switch ((UIDeviceOrientation)[self.currentFragment.orientation unsignedIntValue])
{
case UIDeviceOrientationUnknown:
case UIDeviceOrientationPortrait:
case UIDeviceOrientationFaceUp:
case UIDeviceOrientationFaceDown:
rotationAngle = DEGREES_TO_RADIANS(90);
videoWriterFrameSize = CGSizeMake(dimensions.height, dimensions.width);
break;
case UIDeviceOrientationPortraitUpsideDown:
rotationAngle = DEGREES_TO_RADIANS(-90.0);
videoWriterFrameSize = CGSizeMake(dimensions.height, dimensions.width);
break;
case UIDeviceOrientationLandscapeLeft:
rotationAngle = 0.0;
break;
case UIDeviceOrientationLandscapeRight:
rotationAngle = DEGREES_TO_RADIANS(180.0);
break;
} …
Run Code Online (Sandbox Code Playgroud) 我正在 SymPy 中寻找一种方法来创建函数 (u,v) -> (x,y,z) 将两个元素转换为三个元素,然后从结果向量中取导数。在 Sage 中它看起来像这样:
u = var('u')
v = var('v')
x = (2 + sin(u) *sin(v)) *sin(3*v/2)
y = cos(u) *sin(v) + 2 *v/pi - 2
z = (2 + sin(u) *sin(v)) *cos(3*v/2)
r(u, v) = [x, y, z]
e1 = derivative(r, u)
Run Code Online (Sandbox Code Playgroud) 当我尝试查看堆栈空间内的内容时,我使用以下命令:
x/100x $sp
Run Code Online (Sandbox Code Playgroud)
但是,有时输出的格式如下,按 4 个字节分组:
0xbffff0ac: 0x00000000 0xb7fbc000 0xb7fbc000 0xbffff4e8
...
Run Code Online (Sandbox Code Playgroud)
虽然有时我会得到这个:
0xbffff0ac: 00 00 00 00 00 c0 fb b7 00 c0 fb b7 e8 f4 ff bf
Run Code Online (Sandbox Code Playgroud)
但我无法确定如何在这些格式之间切换以及 gdb 如何决定用于输出的格式。有什么建议?
我正在尝试为按钮和这样的东西补充UIScrollView.我用故事板以图形方式进行,但是当我运行应用程序时它不会滚动.什么可以是我的问题,你知道任何关于UIScrollView在故事板中实现的教程不是为了图像,而是为了按钮,标签的东西?
ios ×4
objective-c ×3
xcode ×2
assembly ×1
avfoundation ×1
c++ ×1
cocoa-touch ×1
debugging ×1
gdb ×1
iphone ×1
linux ×1
memory ×1
protocols ×1
python ×1
qt ×1
sympy ×1
title ×1
uiscrollview ×1
window ×1