我想要实现类似卡纸的东西,里面有文本(标题、描述、页脚)。
我本想使用IBOutletCollection TextView,但我对其他解决方案持开放态度。
我已经将集合从我的xib文件链接到我的界面上。
在我的课堂实现中:
@synthesize myTextViewCollection;
- (void)viewDidLoad {
myTextViewCollection = [NSMutableArray arrayWithObjects:@"one", @"two", @"three", nil];
for (UITextView *myView in myTextViewCollection) {
NSLog(@"%@", myView);
myView.text = @"any text";
}
}myView包含三个字符串:“一”、“二”、“三”。
输出错误:
-[__NSCFConstantString setText:]: unrecognized selector sent to instance 0x461b8我不明白为什么我会犯这个错误..。
谢谢!
发布于 2014-03-18 16:08:00
您的文本视图的IBOutlet是什么?你想要这样的东西:
@property (nonatomic, weak) IBOutlet UITextView* textViewOne;
@property (nonatomic, weak) IBOutlet UITextView* textViewTwo;
@property (nonatomic, weak) IBOutlet UITextView* textViewThree;然后:
for (UITextView *textView in @[ self.textViewOne, self.textViewTwo, self.textViewThree ]) {
textView.text = @"any text";
}您所做的是向数组中添加一组NSString文本,然后尝试将setText:选择器发送到NSString,而不是选择器NSString响应。
https://stackoverflow.com/questions/22484675
复制相似问题