Swift inputAccessoryView override bug

喜你入骨 提交于 2019-12-04 16:44:30
Nikita Ivaniushchenko

This is iOS8 issue with inputAccessoryView autolayout. Issue is that UIToolbar's subview of clas _UIToolbarBackground is not positioned properly during initial layout. Try to do next things:

  1. Make CommentComposeView subclassing UIView, not UIToolbar, add instance of UIToolbar as subview.
  2. Use autolayout masks (not actual constraints) inside your CommentComposeView
  3. Override -layoutSubviews in your CommentComposeView like this:
- (void)layoutSubviews
{
    [super layoutSubviews];

    contentToolbar.frame = self.bounds;
    sendButton.frame = CGRectMake(0.f, 0.f, 44.f, self.bounds.size.height);
    textView.frame = CGRectMake(44.f, 0.f, self.bounds.size.width - 44.f, self.bounds.size.height);
} 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!