小编Sha*_*iel的帖子

Swift中的NSFastEnumeration

我试图将Objective-C项目转换为swift,但我无法找到如何将NSFastEnumeration用于符合NSFastEnumeration的类的对象.

这是ObjC中的代码:

//  get the decode results
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];

ZBarSymbol *symbol = nil;
for(symbol in results)
    // just grab the first barcode
    break;
Run Code Online (Sandbox Code Playgroud)

到目前为止,我试图找到如何做到这一点,但这似乎不起作用,这里是快速的代码:

var results: ZBarSymbolSet = infoDictionary?.objectForKey(ZBarReaderControllerResults) as ZBarSymbolSet

    var symbol : ZBarSymbol? = nil;

    for symbol in results
    {    //just grab first barcode
        break;
    }
Run Code Online (Sandbox Code Playgroud)

条件错误 - "ZBarSymbolSet"没有名为"Generator"的成员

我究竟做错了什么?

这是屏幕截图 在此输入图像描述

objective-c ios swift

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

由于内存错误,应用程序仅在iOS8上崩溃

我正在尝试生成图表并逐个截取屏幕截图.该应用程序正常工作一次然后当我第二次尝试再次捕获屏幕截图时,应用程序崩溃说应用程序因内存错误而终止.这只发生在iOS8而不是iOS7中.这里捕获屏幕截图的代码,它在线崩溃 - [view.layer renderInContext:context]; 应用程序在高峰使用时使用124 MB,并且在崩溃之前没有生成内存警告.即使没有其他应用程序在后台运行,应用程序也会在iOS 8上崩溃.如果我注释掉上面的行,那么应用程序根本不会崩溃,但截图不是完整的屏幕.

- (BOOL)captureView:(UIView *)view forGraph:(NSString *)graphName
{

BOOL isImageCpatured = NO;

@try {
    CGRect rect = view.bounds;
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [view.layer renderInContext:context];
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    CGImageRef imageRef;

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
        imageRef = CGImageCreateWithImageInRect([img CGImage], CGRectMake(0, 113, 1024, 532));
    }
    else {
        imageRef = CGImageCreateWithImageInRect([img CGImage], CGRectMake(0, 93, 1024, 532));
    }

    img = nil;

    UIImage *image = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);        
    NSData *pngData = UIImagePNGRepresentation(image);

    [pngData writeToFile:[Utility_Class documentsPathForFileName:[NSString stringWithFormat:@"%@BG.png",graphName]] atomically:YES];

    pngData = …
Run Code Online (Sandbox Code Playgroud)

memory objective-c ipad ios ios8

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

无法在swift iOS 8 Extension中投射UIImage

我有一个奇怪的问题,我正在尝试构建一个动作扩展,它将从提供的图像中扫描条形码.这是代码.

override func viewDidLoad() {
    super.viewDidLoad()

    // Get the item[s] we're handling from the extension context.

    // For example, look for an image and place it into an image view.
    // Replace this with something appropriate for the type[s] your extension supports.
    var imageFound = false
    for item: AnyObject in self.extensionContext!.inputItems {
        let inputItem = item as NSExtensionItem
        for provider: AnyObject in inputItem.attachments! {
            let itemProvider = provider as NSItemProvider
            if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage as NSString) {
                // This is an image. …
Run Code Online (Sandbox Code Playgroud)

objective-c ios swift ios8 ios-app-extension

8
推荐指数
1
解决办法
2622
查看次数

应用程序仅在xcode乐器中崩溃

我有一个奇怪的问题,我开发了一个应用程序,我从Xcode分析了应用程序,即Xcode>产品>分析,然后修复了我得到的任何内存泄漏.我在ipad模拟器中运行应用程序它工作正常,没有任何崩溃,在iPad设备上运行它;没有崩溃没有任何错误.

但是当我试图从仪器中分析应用程序的内存泄漏时,在分析期间没有内存泄漏,但在一个阶段,当我加载模态视图然后在Modal视图解雇后,应用程序崩溃并且仪器显示模拟器会话超时. 该问题的屏幕截图 可能是什么问题呢 ?

xcode objective-c ipad ios

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

zxing阅读器在横向模式

我有一个问题; 我在我的iPad应用程序中使用了zxing库; 它可以正常读取qr代码.

但它的横向模式阅读器将实时信号从摄像机旋转到90度右侧; 我希望它没有旋转,就像没有旋转的纵向模式一样.

在纵向模式下,视频输入不会旋转;看看 在纵向模式下,视频输入不会旋转;看看

但是在Landscapemodeleft中,视频输入被旋转;再次看一下 在此输入图像描述

xcode zxing ipad ios

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

标签 统计

ios ×5

objective-c ×4

ipad ×3

ios8 ×2

swift ×2

xcode ×2

ios-app-extension ×1

memory ×1

zxing ×1