0
저는 UITextView를 자체 클래스로 가지고 있으며 최대 줄 수를 얻으 려하므로 텍스트가 범위를 벗어나지 않습니다. UITextView는 문자 래핑과 함께 작동하며 항상 래핑 모드로 있어야합니다. 그러나 선 높이 (4.9)는 작동합니다.UITextView의 textContainer 줄 바꿈 및 최대 줄 수가 작동하지 않습니다.
오작동을 일으키는 원인이 무엇인지 확신 할 수 없습니다. 나는 어떤 도움을 주셔서 감사하겠습니다.
CustomTextView.h
#import <UIKit/UIKit.h>
@interface CustomTextView : UITextView <NSLayoutManagerDelegate>
@end
CustomTextView.m
#import "CustomTextView.h"
@implementation CustomTextView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.backgroundColor = [UIColor clearColor];
self.font = [UIFont systemFontOfSize:21.0];
self.dataDetectorTypes = UIDataDetectorTypeAll;
self.layoutManager.delegate = self;
self.tintColor = [UIColor companyBlue];
[self setLinkTextAttributes:@{NSForegroundColorAttributeName:[UIColor companyBlue]}];
self.contentInset = UIEdgeInsetsMake(0.5, 0, 0, 0);
self.scrollEnabled = NO;
self.textContainer.maximumNumberOfLines = 9;
self.textContainer.lineBreakMode = NSLineBreakByCharWrapping;
}
return self;
}
- (CGFloat)layoutManager:(NSLayoutManager *)layoutManager lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(CGRect)rect
{
return 4.9;
}
@end
'self.numberOfLines = 9' 시도해 보셨습니까? 'maximumNumberOfLines'에서 아무 것도 찾을 수 없습니다. – Putz1103
maximumNumberOfLines은 UITextView의 textContainer 속성 – klcjr89
의 속성입니다. 질문에 대답하지 않았습니다. 'self.numberOfLines = 9'을 시도 했습니까? – Putz1103