iOS 转换点 :fromView

标签 ios objective-c

我在 UIView 子类的类中有以下代码片段:

- (FolderWithAttachedLabel *) findFolderContainingPoint: (CGPoint) pointInWindowView
{
    BOOL endOuterLoop = NO;
    for (UIScrollView *scroller in visibleScrollViews)
    {
        for (FolderWithAttachedLabel *subfolder in expandedSubfolderLists)
        {
            CGPoint point = [subfolder convertPoint:pointInWindowView fromView:nil];
            if (CGRectContainsPoint(subfolder.bounds, point))
            {
                [subfolder removeFromSuperview];
                return subfolder;
            }
        }
        if (endOuterLoop)
            break;
    }
    return nil;
}

我试图做的是浏览 UIScrollView 中包含的文件夹列表,以找到用户尝试拖动的文件夹。 FolderWithAttachedLabelUIView 子类。在调试器中,子文件夹看起来是一个有效的实例。

第一次通过内循环时,该行:

CGPoint point = [subfolder convertPoint:pointInWindowView fromView:nil];

抛出以下异常:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM convertPoint:fromView:]: unrecognized selector sent to instance 0xa329890

由于 subfolderUIView 子类,我认为 convertPoint:fromView: 应该是一个很好的选择器,但我显然缺少一些东西。

这里有什么建议吗?

TIA

最佳答案

看起来子文件夹实际上是一个NSArray。我建议查看 expandedSubfolderLists 是如何填充的。

以后,您可以在错误的“原因”中看到:

reason: '-[__NSArrayM convertPoint:fromView:]

__NSArrayMNSArray 类簇的一部分。

关于iOS 转换点 :fromView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16044469/

相关文章:

iphone - 警告 : passing argument 1 of 'setOn:' makes integer from pointer without a cast

objective-c - 释放一个对象后赋值 'nil'有什么用

objective-c - iOS内存管理问题

ios - 我的 ios 开发者帐户无法再访问 “Certificates, Identifiers & Profiles”

ios - IAP 不适用于沙盒商店的 iOS 11

ios - 如何检查外观属性是否已设置?

c++ - include <iostream> 在 ViewController.h 中有效,但在 appDelegate.h 中无效

iPhone RestKit 加载 NSManagedObject 而不是 NSManagedObject+(ActiveRecord)

objective-c - 检查 LXSOCKET (iphone) 中的最后一个错误

ios - Objective C 整数数组