0
滚动不在UITextView中,用于以下代码中的messageLabel sizeDictionary是一个字典,它包含根据文本计算的所有标签/ textview的大小。我已经设置了scrollEnabled以及userInteractionEnabled属性为true。UITextView滚动不起作用
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
self.view.backgroundColor = [UIColor colorWithWhite:0.91 alpha:1];
self.messageLabel = [[UITextView alloc] init];
if(self.feed.message){
self.messageLabel.text = self.feed.message;
}else if (self.feed.story){
self.messageLabel.text = self.feed.story;
}
self.messageLabel.font = [UIFont fontWithName:@"Droid Sans" size:15];
self.messageLabel.editable = NO;
self.messageLabel.dataDetectorTypes = UIDataDetectorTypeAll;
self.messageLabel.scrollEnabled = true;
self.messageLabel.userInteractionEnabled = true;
self.messageLabel.textColor = [UIColor colorWithRed:0.078 green:0.094 blue:0.137 alpha:1.00];
self.cardView = [[UIView alloc] init];
self.cardView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];
[self.view setTranslatesAutoresizingMaskIntoConstraints:false];
self.cardView.frame = CGRectMake(5, 5 + self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width - 10, [self.sizeDictionary[@"imageHeight"] floatValue]+ [self.sizeDictionary[@"messageHeight"] floatValue] + [self.sizeDictionary[@"nameHeight"] floatValue] + 20);
self.cardView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.cardView];
self.nameLabel.frame = CGRectMake(10, 15+ self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width, 51);
self.dateLabel.frame = CGRectMake(15, 45+ self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width, 25);
self.messageLabel.frame = CGRectMake(10, [self.sizeDictionary[@"nameHeight"] floatValue] + 20 + self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width - 20, [self.sizeDictionary[@"messageHeight"] floatValue]);
self.messageLabel.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.messageLabel];
[self.view addSubview:self.dateLabel];
[self.view addSubview:self.nameLabel];
if (self.image) {
self.imageView.frame = CGRectMake(10, [self.sizeDictionary[@"nameHeight"] floatValue] + [self.sizeDictionary[@"messageHeight"] floatValue] + 25 + self.navigationController.navigationBar.frame.size.height , self.view.bounds.size.width - 20, [self.sizeDictionary[@"imageHeight"] floatValue]);
[self.view addSubview:self.imageView];
}
}
编辑:添加
self.messageLabel.layer.borderWidth = 1 ;
self.messageLabel.layer.borderColor = [UIColor redColor].CGColor;
有更多的文字超过8并且被隐藏? –
是的,总共有10分。这个屏幕只是文本来自json的一个例子。在前面的表中调用didSelectAtIndexPath方法时,将显示此视图。文本实际上是在didSelect方法中传递的 –
你可以添加这个代码的和平'self.messageLabel.layer.borderWidth = 1;''self.messageLabel.layer.borderColor = [UIColor redColor] .CGColor;'?并检查您的messageLabel框架是否完全可见? –