找回密码
 立即注册
问题
如何向 UIBarButtonItem 按钮添加滚动(在工具栏上放置多个按钮)?

UI工具栏

非常感谢您的帮助!

回答
替换工具栏的superview:
  1. buttonDone = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(buttonDoneDown)];
  2. NSArray *itemsArray = [NSArray arrayWithObjects:buttonDone, nil];

  3. UIScrollView *scrollView = [[UIScrollView alloc] init];
  4. scrollView.frame = toolbar.frame;
  5. scrollView.bounds = toolbar.bounds;
  6. scrollView.autoresizingMask = toolbar.autoresizingMask;
  7. scrollView.showsVerticalScrollIndicator = false;
  8. scrollView.showsHorizontalScrollIndicator = false;
  9. //scrollView.bounces = false;
  10. UIView *superView = toolbar.superview;
  11. [toolbar removeFromSuperview];
  12. toolbar.autoresizingMask = UIViewAutoresizingNone;
  13. toolbar.frame = CGRectMake(0, 0, X, toolbar.frame.size.height);
  14. toolbar.bounds = toolbar.frame;
  15. [toolbar setItems:itemsArray];
  16. scrollView.contentSize = toolbar.frame.size;
  17. [scrollView addSubview:toolbar];
  18. [superView addSubview:scrollView];
复制代码






上一篇:在不执行请求的情况下合并 github.com 上的分支?
下一篇:精简的 Python 生成器,第二更短:如何检索静默使用的元素