KINWebBrowser

如果想学习使用WKWebView,KINWebBrowser就是一个很不错的模块,它使用iOS8的 WKWebView API编写,同时在iOS 7上使用UIWebView来兼容,源码也很简单,Source:https://github.com/dfmuir/KINWebBrowser.git,下面对其简单介绍一下

1.首先KINWebBrowserViewController must be contained in a UINavigationController.

Pushing to the navigation stack:

KINWebBrowserViewController*webBrowser= [KINWebBrowserViewControllerwebBrowser];[self.navigationController pushViewController:webBrowseranimated:YES];[webBrowserloadURLString:@"https://github.com/dfmuir/KINWebBrowser"];

Presenting Modally:

UINavigationController*webBrowserNavigationController = [KINWebBrowserViewController navigationControllerWithWebBrowser];[selfpresentViewController:webBrowserNavigationController animated:YEScompletion:nil];KINWebBrowserViewController *webBrowser = [webBrowserNavigationController rootWebBrowser];[webBrowser loadURLString:@"https://github.com/dfmuir/KINWebBrowser"];

两种方式都必须包含UINavigationController.

2.效果图

3.自定义

效果图下面的按钮都是作者写好的,如果不符合我们的需求我们可以修改源码进行自定义或者干脆隐藏掉.

按钮自定义部分

- (void)setupToolbarItems {NSBundle*bundle = [NSBundlebundleForClass:[selfclass]];self.refreshButton= [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:selfaction:@selector(refreshButtonPressed:)];self.stopButton= [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:selfaction:@selector(stopButtonPressed:)];UIImage*backbuttonImage = [UIImageimageWithContentsOfFile: [bundle pathForResource:@"backbutton"ofType:@"png"]];self.backButton= [[UIBarButtonItemalloc] initWithImage:backbuttonImage style:UIBarButtonItemStylePlain target:selfaction:@selector(backButtonPressed:)];UIImage*forwardbuttonImage = [UIImageimageWithContentsOfFile: [bundle pathForResource:@"forwardbutton"ofType:@"png"]];self.forwardButton= [[UIBarButtonItemalloc] initWithImage:forwardbuttonImage style:UIBarButtonItemStylePlain target:selfaction:@selector(forwardButtonPressed:)];self.actionButton= [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:selfaction:@selector(actionButtonPressed:)];self.fixedSeparator= [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nilaction:nil];self.fixedSeparator.width=50.0f;self.flexibleSeparator= [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nilaction:nil];}

如果想把下面的所有按钮隐藏,可以通过下面的方法实现

- (void)viewWillAppear:(BOOL)animated {    [superviewWillAppear:animated];    [self.navigationControllersetNavigationBarHidden:NOanimated:YES];    [self.navigationControllersetToolbarHidden:NOanimated:YES];    [self.navigationController.navigationBaraddSubview:self.progressView];    [selfupdateToolbarState];}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • { 11、核心动画 需要签协议,但是系统帮签好 一、CABasicAnimation 1、创建基础动画对象 CAB...
    CYC666阅读 1,589评论 2 4
  • //设置尺寸为屏幕尺寸的时候self.window = [[UIWindow alloc] initWithFra...
    LuckTime阅读 833评论 0 0
  • 1、禁止手机睡眠 [UIApplicationsharedApplication].idleTimerDisabl...
    小热狗阅读 926评论 0 2
  • 冬天了,想吃点羊肉了。 到现在,我还能记老马家的羊杂割,还有我爱吃的小羊腿,我的梦想是在大草原上来一堆烤全羊。 想...
    凡了阅读 679评论 0 8
  • 1.0001年9月30日, 守在红星城里的红军奋不顾身,同命运共呼吸的坚守红军城,敌人火力全开,战士们也不甘落后,...
    刘作家阅读 331评论 0 3