未调用NSLayoutManager Delegate

时间:2016-01-14 09:19:55

标签: ios objective-c layout-manager textkit

我想知道为什么我的委托方法

- (void)layoutManager:(NSLayoutManager *)layoutManager
didCompleteLayoutForTextContainer:(NSTextContainer *)textContainer
                atEnd:(BOOL)layoutFinishedFlag

未调用,我使用此代码:

self.storage = [[NSTextStorage alloc] initWithString:@"sdfsdf sdf sdf sdf sdf sdf Sdf sdf sdf "];
self.layout = [[NSLayoutManager alloc] init];
[self.storage addLayoutManager:self.layout];
self.layout.delegate = self;
NSTextContainer * container = [[NSTextContainer alloc] init];
[self.layout addTextContainer:container];

TextStorage和LayoutManager属性在类中强保留,但委托方法未调用!!!

2 个答案:

答案 0 :(得分:0)

在设置委托后修改NSTextStorage时将调用委托方法。 这是来自UIViewController的片段:

 resources :articles do
  member do
   post 'vote'
  end
 end

答案 1 :(得分:0)

我发现在向UITextView添加任何容器时也会调用委托方法。