【问题标题】:CALayer position contains NaN: [nan -0.5]CALayer 位置包含 NaN:[nan -0.5]
【发布时间】:2010-10-17 07:44:36
【问题描述】:

当我运行我的应用程序时,我在控制台中看到了这个日志:

CALayer position contains NaN: [nan -0.5]

该应用由UITaBar 组成,其中第一个选项卡是UINavigationController。在NavController 中,我正在启动AddressBookPicker。在AddressBookPicker 我只选择显示电话号码。

当我选择只有电子邮件地址的联系人时,我会看到此日志。

我没有看到任何崩溃或任何问题,只是打印到控制台上的日志。想确保这不是在发布后导致我崩溃的隐藏问题。

下面是相关代码的 sn-p 和堆栈跟踪。不确定要在此处粘贴代码的哪些其他部分,如果我可以发布任何可能有帮助的内容,请告诉我。

任何帮助/意见表示赞赏。

谢谢!

代码

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];

NSArray *displayedItems = [NSArray arrayWithObjects: [NSNumber numberWithInt:kABPersonPhoneProperty]), nil];

picker.displayedProperties = displayedItems;

picker.peoplePickerDelegate = self;

[self presentModalViewController:picker animated:YES];

堆栈跟踪

#0    0x00096377 in NSLog

#1    0x046b38c9 in CALayerSetPosition

#2    0x046b3846 in -[CALayer setPosition:]

#3    0x046b375f in -[CALayer setFrame:]

#4    0x002f510b in -[UIView(Geometry) setFrame:]

#5    0x003dbe6d in -[UILabel setFrame:]

#6    0x023ed095 in -[ABPersonTableViewDataSource reloadNoValueLabelAnimated:]

#7    0x0244cf53 in -[ABPersonTableViewDataSource reloadDataIncludingHeaderView:invalidatePropertyData:]

#8    0x023f30d4 in -[ABPersonTableViewDataSource reloadDataIncludingHeaderView:]

#9    0x023eabc9 in -[ABPersonViewControllerHelper prepareViewWithDisplayedProperties:person:allowActions:]

#10    0x023ea6bc in -[ABPersonViewControllerHelper loadViewWithDisplayedProperties:person:allowDeletion:allowActions:]

#11    0x023ea598 in -[ABPersonViewController loadView]

#12    0x0036a54f in -[UIViewController view]

#13    0x003689f4 in -[UIViewController contentScrollView]

#14    0x003787e2 in -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:]

#15    0x00376ea3 in -[UINavigationController _layoutViewController:]

#16    0x0037812d in -[UINavigationController _startTransition:fromViewController:toViewController:]

#17    0x00372ccd in -[UINavigationController _startDeferredTransitionIfNeeded]

#18    0x00379d8b in -[UINavigationController pushViewController:transition:forceImmediate:]

#19    0x00372b67 in -[UINavigationController pushViewController:animated:]

#20    0x02403bc2 in -[ABPeoplePickerNavigationController pushViewController:animated:]

#21    0x0242a424 in -[ABPeoplePickerNavigationController showCardForPerson:withMemberCell:animate:forceDisableEditing:personViewController:]

#22    0x0242ce20 in -[ABMembersViewController showCardForPerson:withMemberCell:animate:]

#23    0x0240a0ef in -[ABMembersController abDataSource:selectedPerson:atIndexPath:withMemberCell:animate:]

#24    0x023fdb47 in -[ABMembersDataSource tableView:didSelectRowAtIndexPath:]

#25    0x00333a48 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]

#26    0x0032a32e in -[UITableView _userSelectRowAtIndexPath:]

#27    0x0003f21a in __NSFireDelayedPerform

#28    0x02631f73 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__

#29    0x026335b4 in __CFRunLoopDoTimer

#30    0x0258fdd9 in __CFRunLoopRun

#31    0x0258f350 in CFRunLoopRunSpecific

#32    0x0258f271 in CFRunLoopRunInMode

#33    0x02f2f00c in GSEventRunModal

#34    0x02f2f0d1 in GSEventRun

#35    0x002ceaf2 in UIApplicationMain

#36    0x00002554 in main at main.m:14

【问题讨论】:

  • 嗨,丹尼,你有没有找到解决这个问题的方法?我收到了相同的错误消息,都是具有不同的 nan 值(?)。有什么导致它的线索吗?

标签: iphone objective-c ios4


【解决方案1】:

现在这似乎会导致 iOS 4.2 崩溃。尝试选择没有电话号码的联系人,您应该转到显示没有电话号码的视图。当您返回所有联系人然后再次选择该联系人时会发生崩溃。

还有其他人遇到这个问题吗?

编辑:就我而言,我只显示电子邮件地址。两次选择没有电子邮件地址的联系人会导致崩溃。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,虽然它似乎没有出现在内置应用程序(例如邮件)中。

    一个稍微有点骇人听闻的解决方法是将名字和姓氏添加到显示的属性列表中 - 在这种情况下它不会显示“无电子邮件地址”层,但也不会崩溃。

    【讨论】:

      【解决方案3】:

      “CALayer 位置包含 NaN:”我遇到了同样的问题。该应用在 iOS3.x 和 iOS4.1 设备上运行良好,但在 iOS4.2 中崩溃。

      就我而言,我有以下代码:

      CGRect frame;
      frame.size.height = kTableCellHeight - 11;
      frame.size.width = widthCell - 30;
      
      UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:frame];
      

      UILabel 创建失败并显示该错误。在我的情况下,解决了为 frame.origin 添加任意值(对于这个 UILabel 目的,没关系)

      CGRect frame;
      frame.size.height = kTableCellHeight - 11;
      frame.size.width = widthCell - 30;
      frame.origin.x = 0;
      frame.origin.y = 0;
      
      UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:frame];
      

      也许“CALayer 位置包含 NaN”的问题是因为使用了一些 nil、不完整或未定义的值或结构。

      【讨论】:

        【解决方案4】:
        1. 我不知道。

        2. 我也看到了 - 我正在做的事情完全与你不同 - 我正在使用 route-me 映射引擎来显示可滚动的地图。

        相信它与 滚动 视图有关 - 以及以某种方式参与滚动的层。正如你提到的一些观点,我认为是滚动的——这与我的观察一致。

        我希望我能为您提供更多数据,但我可以告诉您的一件事是,我已经开发该应用程序 几个月,并且一直在测试它在 iPhone 和 iPad、设备和模拟器上,在 OS 3.2 和 4.0 下 - 并且没有发生崩溃或内存泄漏[根本,或与此相关的]。

        简而言之 - 不知道 - 但我认为你没事!

        【讨论】:

        • 很高兴知道它不会引起问题。开发者社区也没有对此作出回应。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-05-11
        • 1970-01-01
        • 1970-01-01
        • 2012-07-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多