inputAccessoryView现在只读了吗?

时间:2018-02-26 16:13:27

标签: ios objective-c xcode uitextview inputaccessoryview

我有一个Objective-C项目,我想在其中添加一个inputAccessoryView到UITextView的子类。旧的方式是

self.myTextView.inputAccessoryView = myView;

(myView是一个UIView)

现在XCode(9.2)说"分配是readonly属性"

当我尝试使用setter时,像这样:

[self.myTextView setInputAccessoryView: myView];

XCode说"没有可见的@interface为' customTextView'声明选择器' setInputAccessoryView:'"

有人知道为什么会这样吗?以及如何实际设置inputAccessoryView?

非常感谢!

1 个答案:

答案 0 :(得分:-1)

来自UIKit

@property (nullable, readwrite, strong) UIView *inputAccessoryView; //its not read only, its read-write. So you can set it.

所以你可以设置如下......

UIView *customView = [UIView new];
UITextField *txt = [UITextField new];
[txt setInputAccessoryView:customView];

我已经在iOS 11中使用了XCode 9.2