PBWebViewController 0.5.0

PBWebViewController 0.5.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2016 年 2 月

Mikael Konutgan 维护。



  • Mikael Konutgan

PBWebViewController 是 iOS 中的一个轻量级、简单且可定制的网页浏览器组件。它只有 2 个源文件,无图片,大约 300 行代码,并且是用现代 Cocoa 开发技术构建的。

PBWebViewController Screenshot

安装

只需将 PBWebViewController 文件夹拖放到您的项目中或将其添加到您的 Podfile 中。

使用方法

PBWebViewController 在 iPhone 和 iPad 上工作,支持所有方向,并旨在与 UINavigationController 一起使用。您只需要设置其属性,然后将其推入即可。以下是一个简单的示例

// Initialize the web view controller and set it's URL
self.webViewController = [[PBWebViewController alloc] init];
self.webViewController.URL = [NSURL URLWithString:@"http://www.apple.com"];

// These are custom UIActivity subclasses that will show up in the UIActivityViewController
// when the action button is clicked
PBSafariActivity *activity = [[PBSafariActivity alloc] init];
self.webViewController.applicationActivities = @[activity];

// This property also corresponds to the same one on UIActivityViewController
// Both properties do not need to be set unless you want custom actions
self.webViewController.excludedActivityTypes = @[UIActivityTypeMail, UIActivityTypeMessage, UIActivityTypePostToWeibo];

// Push it
[self.navigationController pushViewController:self.webViewController animated:YES];

查看示例项目以了解更多高级用法。

子类化说明

PBWebViewController 可以安全地子类化以实现自定义行为。覆盖 loadUIWebViewDelegate 方法以进行挂钩,但不要忘记调用 super 以利用 PBWebViewController 提供的功能。

示例项目中使用了简单的子类。

关于自定义操作项目和应用程序活动的说明

PBWebViewController 将当前 URL 设置为唯一的操作项目,如果没有提供,则使用此设置。您可以通过这种方式完全自定义在单击操作按钮时显示的所有内容。

另一种实现相同结果的方法是,在子类中覆盖 activityItemsapplicationActivities

请在 PBWebViewController.m 中的 action: 方法查看更多详细信息。

贡献

  1. 分支
  2. 创建您的特征分支(git checkout -b my-new-feature
  3. 提交您的更改(git commit -am 'Add some feature'
  4. 推送到分支(git push origin my-new-feature
  5. 创建新的 Pull Request