gpt4 book ai didi

ios - 我的 UIPopoverBackgroundView 子类无法访问 UIPopoverBackgroundView 的实例变量

转载 作者:行者123 更新时间:2023-11-28 21:21:11 28 4
gpt4 key购买 nike

我创建了一个类,它是 UIPopoverBackgroundView 的子类:

@interface TestPopView : UIPopoverBackgroundView

@end

在我尝试访问 UIPopoverBackgroundView 类的属性 arrowOffset 的地方。

enter image description here

但是当我在我的子类中实现一个方法时,我想直接访问 arrowOffset(使用 _arrowOffset 形式,而不是使用 getter&setter ) ,编译器提示“使用未声明的标识符 _arrowOffset

enter image description here

什么原因,我无法访问属性目录?

最佳答案

实例变量 _arrowOffset 是父类(super class)的私有(private) iVar,因此子类不能直接访问它。您可以使用 getter/setter 在子类中使用它,这很有效。

关于ios - 我的 UIPopoverBackgroundView 子类无法访问 UIPopoverBackgroundView 的实例变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39764413/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com