小编joh*_*doe的帖子

使用AVAssetWriter捕获屏幕 - 在模拟器上正常工作但在设备上创建黑色视频

即时通讯尝试捕获帧缓冲区数据并转换为我的iPhone游戏的视频..即时通讯使用AVAssetWriter来完成这件事.代码在模拟器上工作正常,但在设备本身没有.在设备上它生成一个黑色视频

即时通讯使用以下代码:

//This code initializes the AVAsetWriter and other things

- (void) testVideoWriter {
    CGRect screenBoundst = [[UIScreen mainScreen] bounds];
    //initialize global info
    MOVIE_NAME = @"Documents/Movie5.mp4";
    //CGSize size = CGSizeMake(screenBoundst.size.width, screenBoundst.size.height);
    CGSize size = CGSizeMake(320, 480);
    frameLength = CMTimeMake(1, 5); 
    currentTime = kCMTimeZero;
    currentFrame = 0;

    MOVIE_PATH = [NSHomeDirectory() stringByAppendingPathComponent:MOVIE_NAME];
    NSError *error = nil;

    videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:MOVIE_PATH]
                                            fileType:AVFileTypeMPEG4 error:&error];

    NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:AVVideoCodecH264, AVVideoCodecKey,
                                   [NSNumber numberWithInt:size.width ], AVVideoWidthKey,
                                   [NSNumber numberWithInt:size.height ], AVVideoHeightKey, nil];

    writerInput = [AVAssetWriterInput …
Run Code Online (Sandbox Code Playgroud)

video ipad avassetwriter

6
推荐指数
0
解决办法
1663
查看次数

有没有办法可以操作父视图控制器,以便子视图位于UIPageControl下面?

我通过使用UIPageViewController在应用程序中实现水平滚动,我将导航属性设置为"Horizo​​ntal",将Transistion Style设置为"scroll".一切正常,我可以添加一些正确呈现的子视图.我还想通过使用这两种方法来利用UIPageViewController所具有的内置UIPageControl:

-(NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
-(NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
Run Code Online (Sandbox Code Playgroud)

这实际上显示了我正在寻找的东西:指示显示哪个子视图的点.但是,正如您在图像中看到的那样,UIPageControl设置在父视图控制器(UIPageViewController)的底部.您可以想象这不是我想要呈现我的UIPageControl的方式.有没有办法可以操作父视图控制器,以便子视图位于UIPageControl下面?还是有其他好的做法来实现这一目标吗?我知道我可以通过使用scrollView而不是UIPageViewController来实现水平滚动,但这似乎对我来说效率更高.

http://i48.tinypic.com/2hd03ev.png

为清晰起见:灰色部分是我的子视图,红色部分是我正在使用的底层UIPageViewController.

提前感谢您的回答!

objective-c uipagecontrol layoutsubviews uipageviewcontroller

6
推荐指数
1
解决办法
1385
查看次数

进入全屏时,嵌入在UIWebView中的Youtube在iPad上导致崩溃

我正在尝试使用这种技术的混合物来嵌入Youtube视频,并将此Youtube SDK博客文章嵌入通用应用中。使用相同代码的iPhone版本可以正常工作。在iPad上,视频确实被嵌入,并且可以以嵌入形式很好地播放,但是一旦您点击全屏按钮,应用就会崩溃(按钮不响应,设备不会旋转)。YouTube视频中的音乐一直在播放。

没有记录错误消息,但该应用程序确实注册为“已暂停”或挂在xCode中。每次崩溃com.apple.libdispatch-manager都在线程2上。问我问题,我将为您提供有关该错误的更多信息,但我不确定从哪里开始。

我试过了:

  • 更改UIWebView框架的大小
  • UIWebView在UIScrollView中,但是如果我从scrollview中取出并将其添加到视图中,则问题是相同的。
  • 更改视频
  • 将我在UIWebView中使用的html从this更改为this,没有结果
  • 将youtube链接的格式从?v = uniqueID更改为/ v / uniqueID
  • 检查呈现视图的是rootviewcontroller(是的,但是视频嵌入在模式中,而不是rootviewcontroller)。

我正在为iOS 5.1进行构建,如果在iOS6上运行则不会发生这种情况

嵌入视频的视图在手机和iPad上都是模态的。该应用程序中没有黑客或异常事件。

似乎有人说Evernote的应用程序有类似的问题,但我不知道它是否相关。

供您参考,这是YouTubeView子类(它是UIWebView的子类):

- (YouTubeView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame;
{
    if (self = [super init]) 
    {
        // Create webview with requested frame size
        self = [[YouTubeView alloc] initWithFrame:frame];

// HTML to embed YouTube video
//      NSString *youTubeVideoHTML = @"<html><head>
//                                       <body style=\"margin:0\">
//                                         <embed id=\"yt\" src=\"%@\"
//                                                type=\"application/x-shockwave-flash\"
//                                                width=\"%0.0f\" …
Run Code Online (Sandbox Code Playgroud)

youtube objective-c hang ipad ios

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

为什么AVAssetExportSession会生成一个空文件?

我正在尝试从UIImagePickerController创建的源视频中导出.mov文件.问题是输出文件AVAssetExportSession创建的只有668个字节.它为什么失败?我的代码:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSURL *imagePickerVideoURL = [info objectForKey:UIImagePickerControllerMediaURL];
    NSString *filename = @"vid1.mov";

    AVAsset *video = [AVAsset assetWithURL:imagePickerVideoURL];
    AVAssetExportSession *exportSession
      = [AVAssetExportSession exportSessionWithAsset:video presetName:AVAssetExportPresetMediumQuality];
    exportSession.shouldOptimizeForNetworkUse = YES;
    exportSession.outputFileType = AVFileTypeQuickTimeMovie;
    exportSession.outputURL = [pathToSavedVideosDirectory URLByAppendingPathComponent:filename];
    NSLog(@"processing video...: %@", exportSession);
    [exportSession exportAsynchronouslyWithCompletionHandler:^{
                       NSLog(@"done processing video!");
                   }];
}
Run Code Online (Sandbox Code Playgroud)

video objective-c avfoundation ios avassetexportsession

4
推荐指数
2
解决办法
4979
查看次数

隐藏状态栏

我希望在我的应用程序中以全屏显示ViewControllers之一的视图,因此在Interface Builder中,我将状态栏设置为None.我还将视图的大小调整为320*480

但是当我运行应用程序时,viewcontroller的视图仍然显示状态栏.

欢迎任何评论

谢谢

替代文字

iphone statusbar

3
推荐指数
1
解决办法
1549
查看次数

在不同的数组UICollectionView中添加不同部分的选定单元格

我想UICollectionView在数组中添加选定的单元格,在不同的数组中分段,表示每个部分的不同数组.问题在于这些部分是动态的.以下是我的代码.

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *seatV;
    int cs;

    NSString *secVal = [arrSeatSel objectAtIndex:indexPath.section];
    NSArray *arrSplit = [secVal componentsSeparatedByString:@":"];
    seatV = [arrSplit objectAtIndex:1];
    cs = [seatV integerValue];

    int v;
    NSString *cnt = [NSString stringWithFormat:@"%@",[arrTot objectAtIndex:indexPath.section]];
    v = [cnt intValue];

    NSString *sect = [NSString stringWithFormat:@"%d", indexPath.section];

    if(indexPath.item < v)
    {
        if([sectionInfo count] < cs)
        {
            itemPaths = [self.collectionView indexPathsForSelectedItems];

            sectionInfo = [NSMutableArray arrayWithArray: [self.collectionView indexPathsForSelectedItems]];
            [selectedItemsInfo setObject:sectionInfo forKey:sect];
            cell=[self.collectionView cellForItemAtIndexPath:indexPath];
            cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yellow_seat.png"]];                    
        }

        else …
Run Code Online (Sandbox Code Playgroud)

iphone ios uicollectionview

3
推荐指数
1
解决办法
1446
查看次数

Xcode"使用未声明的标识符"

我知道很多人问这个,但所有答案都是特定的应用程序,所以我不明白如何为我的应用程序工作.

        tableData = [NSArray arrayWithObjects:@"Chocolate Brownie", @"Mushroom Risotto", nil];
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section
    {
        return [tableData count];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *simpleTableIdentifier = @"SimpleTableItem";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
        }

        cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
        return cell;` 
    }
Run Code Online (Sandbox Code Playgroud)

iphone xcode uitableview

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

为什么Xcode/clang将我的"-fno-objc-arc"翻译为"-fno_objc_arc"?

我试图按照SF的建议,通过在我的构建阶段的"编译源"部分的文件的编译标志中放置"-fno-objc-arc"来关闭一个文件的每个文件的Objective-C arc对于我的项目.

这对我不起作用,因为仍然会生成与ARC相关的错误.

我在日志中看到我试图执行此操作的文件以下警告:

"clang:warning:编译期间未使用的参数:' - fno_objc_arc'"

我注意到它显示下划线而不是破折号.当我查看生成的编译行时,它还会显示下划线而不是破折号.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c
-arch armv7 -fmessage-length=0 -std=gnu99 -fobjc-arc -Wno-trigraphs -fpascal-strings -O0
-Werror-implicit-function-declaration -Wmissing-field-initializers -Wno-missing-prototypes -Wreturn-type
-Wno-implicit-atomic-properties -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function
-Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wno-unknown-pragmas
-Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof
-Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
-Wprotocol -Wdeprecated-declarations -g -Wno-conversion -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))"
"-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)"
-miphoneos-version-min=5.1 -iquote /x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/myproj.build/Debug-iphoneos/myproj.build/myproj-generated-files.hmap
-I/x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/myproj.build/Debug-iphoneos/myproj.build/myproj-own-target-headers.hmap
-I/x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/myproj.build/Debug-iphoneos/myproj.build/myproj-all-target-headers.hmap
-iquote /x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/myproj.build/Debug-iphoneos/Voyeur.build/myproj-project-headers.hmap
-I/x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Products/Debug-iphoneos/include
-I/x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/myproj.build/Debug-iphoneos/myproj.build/DerivedSources/armv7
-I/x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/myproj.build/Debug-iphoneos/myproj.build/DerivedSources
-F/x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Products/Debug-iphoneos -fno_objc_arc
-include /x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/PrecompiledHeaders/myproj-Prefix-adnhewmpoabuzebrrqoplkebnugj/myproj-Prefix.pch
-MMD -MT dependencies -MF /x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/myproj.build/Debug-iphoneos/myproj.build/Objects-normal/armv7/mySource.d
--serialize-diagnostics /x/xcode/DerivedData/myproj-eqyvffptnyujnsgcmhlqunfmfytp/Build/Intermediates/myproj.build/Debug-iphoneos/myproj.build/Objects-normal/armv7/mySource.dia
-c /x/git/myproj/subdir/mySource.m …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c clang automatic-ref-counting

0
推荐指数
1
解决办法
3610
查看次数