- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我的应用程序有一个包含每日报价的部分,该报价是从互联网上的网页中提取的。我一直在尝试使用 Today Extension 添加报价,以便可以在那里查看,但扩展始终显示为空白。
我在 Storyboard中添加了 Today Extension 文件,并且在我拥有的代码的实现文件中:
#import "TodayViewController.h"
#import <NotificationCenter/NotificationCenter.h>
@interface TodayViewController () <NCWidgetProviding>
@end
@implementation TodayViewController
-(void)viewDidLoad {
[super viewDidLoad];
self.title = @"Today's Scripture";
self.preferredContentSize = CGSizeMake(320, 50);
[reader loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.316apps.com/testingdailyreader.html"]cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]];
// timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(tick) userInfo:nil repeats:YES];
}
@end
但是,我得到的只是通知中心中显示“无法加载”的空白行。我做错了什么?
最佳答案
下面是我如何从 UIWebView 过渡到 WKWebView。
注意:没有像 UIWebView 这样的属性可以拖到 Storyboard上,您必须以编程方式进行。
确保将 WebKit/WebKit.h 导入头文件。
#import <WebKit/WebKit.h>
这里,实现:
#import "ViewController.h"
@interface ViewController ()
@property(strong,nonatomic) WKWebView *webView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.productURL = @"http://www.URL YOU WANT TO VIEW GOES HERE";
NSURL *url = [NSURL URLWithString:self.productURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
//[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.316apps.com/testingdailyreader.html"]cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]];
_webView = [[WKWebView alloc] initWithFrame:self.view.frame];
[_webView loadRequest:request];
_webView.frame = CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:_webView];
}
@end
关于ios - 今天扩展 UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25999061/
我找到了很好的函数 =GOOGLEFINANCE("AAPL";"price";TODAY(); today()-60) 可以给出指定日期范围内的股票价格 - 它工作正常。我试图用它来获取 EPS 或
基于云计算的大规模即时云渲染技术,让每个人都拥有了“数字生命”。 2023的开年爆款,非《流浪地球2》莫属。 它展开了人类的新话题,关于平行空间,关于数字生命,关于人类文明
我试图过滤掉比今天更大的日期。我查找了语法,但日期部分不起作用;我仍然在结果中得到日期 > 今天。 有人可以帮我解决这个问题吗?!谢谢!这是查询: =iferror(sort(if(isblank(S
这就是我现在所拥有的: set_time_limit(120); $now = (new \DateTime)->format('Y-m-d H:i:s'); $nowYmd = (new \Date
这个问题在这里已经有了答案: 关闭 12 年前。 Possible Duplicate: Select * from table where date = today 你好,我正在尝试做一个 mys
我使用 CouchDB 作为事件日志,我想在它之上构建简单的 UI,以便我可以更轻松地查询事件。 我可以使用原始 HTTP 调用并手动构建 View ,也可以使用 CouchApp 框架。 问题是这些
我似乎无法在“小部件模拟器”中运行“今日”小部件(或与此相关的任何扩展名)。模拟器启动,并说“无法打开小部件”以及 Failed to find Widget /Users/SomeUser/Libr
我正在使用来自此来源的日期选择器 http://jqueryui.com/datepicker/#buttonbar ,我正在尝试让按钮栏上的“今天”按钮处于事件状态,请任何人帮助我。 $(".dat
我是Prometheus和警报方面的新手,我无法通过查看文档来完善答案。 我有一些数据即将进入Elasticsearch集群。每天,该过程都会在Elasticsearch上创建一个新索引,并将当天的数
我有一个应用程序和一个今天的扩展程序,它们使用安全组标识符共享Core Data持久性存储。 主应用程序更新Core Data存储,而扩展名仅从存储中读取。 我在应用程序和扩展程序中都使用了NSFet
我在项目中完成了Today扩展的一半。 我不必向公众发布半成品,但也希望保持相同的代码库,这样可以节省代码维护时间。 没有人知道没有内置“今日”扩展程序的发布应用程序的方法吗? 谢谢 最佳答案 在应用
我花了很长时间来了解段注册的内容目的是?我已经准备好知道这来自过去 (8086)只有 1 MByte 的物理内存。但是CPU有只有 16 位宽的地址寄存器。有了这 16 个地址位你只能寻址 64K 字
我有一个表格,其中包含成员(member)加入俱乐部时输入的日期。该列是沼泽标准,类型为 DATE。不需要时间。 基本上,我正在尝试找到一种 future 不可能的方式? 最佳答案 您可以使用触发器。
我需要获取早于或等于今天的日期。我正在使用 C# LINQ。 只是想知道以下是否是最有效的方法: pr.PgDate >= DateTime.Today 最佳答案 视情况而定,假设您使用的是将其直接转
$str = 'BEGIN This is a "quote" test. \'Single\' END'; echo $str . "\n"; echo mysql_real_escape_stri
在 HTML 5 中是否支持在 Silverlight 中真正容易做到的事情? 例如,将一个文件(由用户选择)转换为一个字节数组,该字节数组可以进行 base64 编码并传递给网络服务? 或者,创建/
使用 Oracle,如何在 11:59:59 选择当前日期(即 SYSDATE)? 考虑到午夜的定义might be a little ambiguous (星期四午夜是指跨越星期四和星期五还是跨越星
My Today 扩展需要有一个基于小部件显示内容的动态高度。我能够通过在最底部元素上添加约束来实现这一点:底部布局指南的顶部小于或等于最底部元素的底部,常量为 0,优先级为 999,乘数为 1。 这
我相信你们中的许多人已经查看了今天的 (2011-02-08) Google's doodle (link to article on CNN if doodle changes)。这太棒了,我试着弄
如下所示: ? 1
我是一名优秀的程序员,十分优秀!