Сегодня расширение UIWebView

В моем приложении есть раздел с ежедневной цитатой, и эта цитата взята с веб-страницы в Интернете. Я пытался добавить цитату с помощью расширения «Сегодня», чтобы ее можно было просмотреть там, но расширение постоянно отображается пустым.

Я добавил файл расширения Today с раскадровкой, а в файле реализации для кода у меня есть:

#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

Однако все, что я получаю, это пустая строка с надписью «Невозможно загрузить» в Центре уведомлений. Что я делаю неправильно?


person user717452    schedule 23.09.2014    source источник
comment
вы нашли решение этой проблемы? у меня такая же проблема сейчас   -  person cptdanko    schedule 06.03.2016


Ответы (1)


Вот как я перешел с UIWebView на WKWebView.

Примечание. Нет такого свойства, как UIWebView, которое вы можете перетащить на свою раскадровку, вы должны сделать это программно.

Убедитесь, что вы импортировали 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
person itechnician    schedule 26.04.2016