Successfully reported this slideshow.

俩控件

985 views

Published on

自定义webview控件和navigationController控件介绍

Published in: Technology, Art & Photos
  • Be the first to comment

  • Be the first to like this

俩控件

  1. 1. 俩控件QMWebView QMNavigationController bangchen
  2. 2. QMWebView
  3. 3. UIWebViewUIWebViewScrollView UIImageView * x UIWebBrowserView
  4. 4. contentInset.topscrollView.contentSize webView.frame contentInset.right contentInset.left contentInset.bottom
  5. 5. 接口@property (nonatomic, retain) UIView *footerView;@property (nonatomic, retain) UIView *headerView;- (void) headerViewHeightChange:(int)height animated:(BOOL)animated;- (void) footerViewHeightChange:(int)height;- (void) refresh;
  6. 6. 内部工作
  7. 7. 给webview设header/footer时计算contentInset
  8. 8. header, footer高度改变的位置调整/动画
  9. 9. webview 动/缩放时header/footer的位置
  10. 10. contentSize改变时footer的位置
  11. 11. 困难
  12. 12. iOS4 webview加载完成,自动跳到contentOffsetY=0 loading finish
  13. 13. 解决:加标志- (void)loadRequest:(NSURLRequest *)request{! _startLoad = YES;}- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (_startLoad && scrollView.contentOffset.y == 0) { _startLoad = NO; scrollView.contentOffset = CGPointMake(0, -scrollView.contentInset.top); return ; }}
  14. 14. 上一个内容的残影[webview stringByEvaluatingJavaScriptFromString: @"document.open();document.close()"]; ornew webview
  15. 15. 莫名黑色块 opaque = NO;
  16. 16. QMNavigationController
  17. 17. 问题:自定义navigationItem.leftBarButtonItem无动画
  18. 18. 已有信息- (UIViewController *)popViewControllerAnimated:(BOOL)animated- (void)pushViewController:(UIViewController *)viewControlleranimated:(BOOL)animated @property(nonatomic,copy) NSArray *viewControllers; // The current view controller stack.
  19. 19. 在push与pop 个方法执行前加入动画逻辑if (animated) {! ! UIViewController *popController = [self.viewControllers lastObject];! ! UIViewController *pushController = [self.viewControllers objectAtIndex:self.viewControllers.count - 2];! ! [popController viewDisappearFromLeft];! ! [pushController viewAppearFromLeft];! }! return [super popViewControllerAnimated:animated];
  20. 20. END

×