小编wom*_*t57的帖子

AVVideoCompositionCoreAnimationTool和CALayer处于纵向模式?

我正在尝试使用iOS 4.3上的AVMutableComposition,AVMutableVideoComposition和AVVideoCompositionCoreAnimationTool将CALayer烘焙成纵向模式视频(导出时).这一切都在景观中起作用.但是,如果我以纵向捕捉视频,AVVideoCompositionCoreAnimationTool将忽略视频轨道上的变换.也就是说,对于纵向模式视频,我将AVMutableCompositionTrack.preferredTransform设置为原始资产视频轨道中的preferredTransform值.只要我不使用AVVideoCompositionCoreAnimationTool,这就可以了,视频以纵向模式显示.但是,只要我添加AVVideoCompositionCoreAnimationTool和CALayer,该文件就会出现.(CALayer显示正确,但背后的视频位于其侧面,并且文件的宽高比关闭).我尝试将变换应用于CALayer,并在ACVideoComposition中设置变换.这些都不会改变生成的文件的方向(它仍然是480x369,而不是360x480).有没有办法用AVVideoCompositionCoreAnimationTool渲染肖像模式视频?

首先,我设置了一个AVMutableComposition和AVMutableVideoComposition

AVMutableComposition *composition = [AVMutableComposition composition];
AVMutableCompositionTrack *compositionVideoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
AVURLAsset *videoAsset = [AVURLAsset URLAssetWithURL:url options:nil];
CMTimeRange timeRange = CMTimeRangeMake(kCMTimeZero, [videoAsset duration]);
AVAssetTrack *clipVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];

CGSize videoSize = CGSizeApplyAffineTransform(clipVideoTrack.naturalSize, clipVideoTrack.preferredTransform);
videoSize.width = fabs(videoSize.width);
videoSize.height = fabs(videoSize.height);

CMTime titleDuration = CMTimeMakeWithSeconds(5, 600);
CMTimeRange titleRange = CMTimeRangeMake(kCMTimeZero, titleDuration);

[compositionVideoTrack insertTimeRange:titleRange ofTrack:nil atTime:kCMTimeZero error:nil];
[compositionVideoTrack insertTimeRange:timeRange ofTrack:clipVideoTrack atTime:titleDuration error:nil];
compositionVideoTrack.preferredTransform = clipVideoTrack.preferredTransform;

AVMutableVideoComposition *videoComposition = [AVMutableVideoComposition videoComposition];
AVMutableVideoCompositionInstruction *passThroughInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
passThroughInstruction.timeRange = CMTimeRangeMake(kCMTimeZero, [composition …
Run Code Online (Sandbox Code Playgroud)

avfoundation ios avassetexportsession

14
推荐指数
1
解决办法
5950
查看次数

CoreData对多对多关系进行排序

我正在编写一个iOS应用程序,它具有人员记录存储,并且需要显示以特定方式排序的列表.这些排序有可变数量,它们是动态生成的,但我希望它们存储在数据存储区中.执行此操作的SQL方法是使ListPositions表具有列表名称,人员表中的id和排序键.然后,为了显示特定列表,我可以选择具有给定名称的所有列表ListPosition,拉入引用的人员,并对排序键进行排序.尝试在CoreDatat中执行此操作,但是我遇到了问题.我试图使用如下架构来做到这一点:

Person:
    Name
    DOB
    etc... 
    positions -->> ListPosition

ListPosition:
    listName
    sortKey
    person --> Person
Run Code Online (Sandbox Code Playgroud)

然后,我可以使用NSPredicate获取给定列表中的所有人员 [NSPredicate predicateWithFormat:@"ANY positions.listName like %@", someList]; 这允许我针对大量人员动态添加列表.问题是我无法使用ListPosition的sortKey字段对Persons进行排序.NSSortDescriptor会做什么?如果无法对多对多关系的一个元素的属性进行获取,那么在coredata中获取多个动态排序的另一种方法是什么?我正在使用NSFetchedResultsController显示列表,因此我无法将这些列表放在内存中.我需要使用单个NSFetchRequest来完成它.

iphone cocoa-touch core-data nssortdescriptor ios

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

检测iOS设备方向锁定

如何以编程方式检查iOS中的设备方向是否已锁定?我在UIDevice中什么都看不到.我知道这应该对应用程序透明.但是如果方向被锁定,我想改变显示内容的方式(正如Youtube应用程序所做的那样;它会锁定到横向而不是纵向).这一定是可能的.

iphone orientation ios

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

当UIAlertView在屏幕上时,无法在UIViewController堆栈中隐藏键盘

我花了大约一天的时间来追踪一个非常奇怪的情况,即在活动的UITextField上调用resignFirstResponder并没有隐藏键盘,即使textfield是第一个响应者.当我将视图控制器推送到具有活动文本字段的另一个视图控制器之上时,会发生这种情况.键盘消失(正如预期的那样).但是,如果我通过触摸第二个视图控制器中的文本字段将键盘带回,则后续调用resignFirstResponder无效.

这是重现问题的简单代码.此代码是一个视图控制器,带有一个用于隐藏键盘的导航栏按钮,另一个用于推送其自身的另一个副本(带有确认UIAlertView).第一个副本没有问题.但是,如果您按第二个副本(当第一个副本具有可见键盘时),则无法关闭键盘.只有在按下第二个副本时屏幕上有UIAlertView(确认)时才会发生这种情况.如果删除该#define ALERT行,一切正常.

有谁知道这里发生了什么?看起来UialertView窗口在某种程度上干扰了键盘并使其窗口不再消失,从而混淆了下一个视图.在UIALertView消失后,除了在计时器上按下第二个视图控制器之外,还有其他解决方案吗?

对不起复杂的描述.这是可运行的代码.我希望代码清楚.

@implementation DemoViewController

- (id) init {
    if (!(self = [super init])) 
        return nil;

    return self; 
}

- (void) dealloc {
    [_inputTextfield release];
    [super dealloc];
}

- (void) loadView {
    UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];

    _inputTextfield = [[UITextField alloc] initWithFrame:CGRectMake(0., 0., 320., 44.)];
    _inputTextfield.borderStyle = UITextBorderStyleRoundedRect;
    _inputTextfield.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    _inputTextfield.keyboardAppearance = UIKeyboardAppearanceAlert;
    _inputTextfield.autocapitalizationType = UITextAutocapitalizationTypeNone;
    _inputTextfield.autocorrectionType = UITextAutocorrectionTypeNo;
    _inputTextfield.keyboardType = UIKeyboardTypeDefault;
    [view addSubview:_inputTextfield];

    self.view = view;
    [view release];
}

- (void) viewWillAppear:(BOOL) …
Run Code Online (Sandbox Code Playgroud)

keyboard cocoa-touch uikit uialertview ios

5
推荐指数
1
解决办法
2900
查看次数

从iOS(OopenGL-ES)中的屏幕外OpenGL像素缓冲区读取像素

我想读取屏幕外的像素(没有CAEAGLLayer支持)Framebuffer.我创建缓冲区的代码如下:

glGenFramebuffersOES(1, &_storeFramebuffer);
glGenRenderbuffersOES(1, &_storeRenderbuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, _storeFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, _storeRenderbuffer);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES,   GL_RENDERBUFFER_OES, _storeRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGBA8_OES, w, h);
Run Code Online (Sandbox Code Playgroud)

我读了原始像素:

glBindFramebufferOES(GL_FRAMEBUFFER_OES, _storeFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, _storeRenderbuffer); 
glReadPixels(0, 0, _videoDimensions.width, _videoDimensions.height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, CVPixelBufferGetBaseAddress(outPixelBuffer)); 
Run Code Online (Sandbox Code Playgroud)

这很好用.我可以渲染到这个缓冲区,并从它复制到屏幕.但我不能得到原始像素.glReadPixels总是返回零,并且glReadBuffer似乎不存在.我可以使用glReadPixels从屏幕上的帧缓冲区中读取.有任何想法吗?

opengl-es ios

4
推荐指数
1
解决办法
2906
查看次数