相关疑难解决方法(0)

iOS 7 UITextView中的换行符打破了Text Kit排除区域换行

我正在使用iOS 7中的Text Kit,我在NSTextContainer禁区附近发现了很多奇怪的东西.

我有两种观点:a UITextView和简单的可拖动UIView; 作为UIView移动,我从UIView框架创建了一条bezier路径(调整到UITextView坐标空间内)并更新了UITextViews NSTextContainerexclusionPaths数组 - 非常简单.

在第一个屏幕截图中,您可以看到Text Kit很好地将文本包装在矩形排除区域周围:

禁区,文本中没有换行符

但是,当用户在其中引入换行符时UITextView,TextKit似乎认为禁区的垂直区域要大得多 - 看起来与换行符创建的空格一样高.bezier路径完全相同,所以这似乎是一个Text Kit问题(除非我做错了).

带有文本换行符的禁区

码:

ViewController.h:

@interface ViewController : UIViewController<UITextViewDelegate>

@property (nonatomic, strong) IBOutlet UITextView *textView;
@property (nonatomic, strong) IBOutlet UIView *dragView;

@end
Run Code Online (Sandbox Code Playgroud)

ViewController.m:

-(void)viewDidLoad
{
    [super viewDidLoad];

    UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
    [panRecognizer setMinimumNumberOfTouches:1];
    [panRecognizer setMaximumNumberOfTouches:1];
    [self.dragView addGestureRecognizer:panRecognizer];

    [self updateExclusionZone];
}

-(void)move:(UIPanGestureRecognizer *)pan
{
    [self.view bringSubviewToFront:[pan view]];

    if …
Run Code Online (Sandbox Code Playgroud)

objective-c ipad ios7 textkit

5
推荐指数
1
解决办法
3176
查看次数

标签 统计

ios7 ×1

ipad ×1

objective-c ×1

textkit ×1