【问题标题】:Can i list possible source types as ones not available?我可以将可能的源类型列为不可用的吗?
【发布时间】:2012-06-14 17:26:13
【问题描述】:

我目前有这个代码:

NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:imagePicker.sourceType];
imagePicker.mediaTypes = mediaTypes;

但它导致了这个泄漏:

figremote_createpropertylistfrombinaryplistdata

有人说用这个代替它:

CFStringRef mTypes[2] = { kUTTypeImage, kUTTypeMovie };

CFArrayRef mTypesArray = CFArrayCreate(CFAllocatorGetDefault(), (const void**)mTypes, 2, &kCFTypeArrayCallBacks);

imagePicker.mediaTypes = (NSArray*)mTypesArray;

CFRelease(mTypesArray);

问题是,有些设备没有电影模式。如果我允许该模式但它不可用会导致问题吗?

【问题讨论】:

    标签: iphone objective-c ios memory-leaks uiimagepickercontroller


    【解决方案1】:

    据我所知,没有不支持视频模式的设备。如果设备不支持视频模式,则它根本不支持摄像头。我的建议是检查设备是否完全支持相机。在这种情况下,下面的代码就可以了。

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        NSLog(@"Device supports camera");
    } else {
        NSLog(@"Device does not support camera");
    }
    

    【讨论】:

      猜你喜欢
      • 2015-07-14
      • 2021-03-03
      • 2022-08-17
      • 2011-01-25
      • 2012-03-31
      • 2011-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多