我想在IOS8上使用WKWebView,但也需要IOS7的兼容性,我看过帖子指的是使用这段代码:
if ([WKWebView class]) {
// do new webview stuff
}
else {
// do old webview stuff
}
Run Code Online (Sandbox Code Playgroud)
但不确定我做错了什么,因为下面的代码给我一个链接器错误:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_WKWebView", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
任何帮助非常感谢,这是我的代码:
.h文件:
#import "WebKit/WebKit.h"
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *contentWebView;
@property (weak, nonatomic) IBOutlet WKWebView *contentWKWebView;
@end
Run Code Online (Sandbox Code Playgroud)
.m文件:
#import "ViewController.h"
@interface ViewController …Run Code Online (Sandbox Code Playgroud) 这段代码的工作原理:
if ((filenameTmp == "thunderstorm") ||
(filenameTmp == "fog") ||
(filenameTmp == "hail") ||
(filenameTmp == "heavy_snow") ||
(filenameTmp == "rain") ||
(filenameTmp == "sleet") ||
(filenameTmp == "snow"))
{ document.getElementById("twilightBG").style.display = "none"; }
Run Code Online (Sandbox Code Playgroud)
不过我想缩短它,我认为这会起作用,但事实并非如此。
if(filenameTmp.indexOf ("thunderstorm", "fog", "hail", "heavy_snow", "haze", "sleet", "snow")> -1)
{ document.getElementById("twilightBG").style.display = "none"; }
Run Code Online (Sandbox Code Playgroud)
如果我只有一个这样的搜索,它确实有效:
if(filenameTmp.indexOf ("haze")> -1)
{ document.getElementById("twilightBG").style.display = "none"; }
Run Code Online (Sandbox Code Playgroud)
我怎样才能搜索多个实例?或者,还有更好的方法?谢谢。
在天气小部件中,我有一个小时预测的循环,但是我需要将它分成4行而不是一行包含12个项目,如何每隔3次添加换行符?这是我的for循环:
for (var i = 0; i<12; i++) {
document.getElementById("Hicon" + i).style.left = 1.4 + 8.333*i + "%";
document.getElementById("Hpop" + i).style.left = 2.5 + 8.333*i + "%";
document.getElementById("Hour" + i).style.left = 1.57 + 8.333*i + "%";
document.getElementById("Htemp" + i).style.left = 1.3 + 8.333*i + "%";
}
Run Code Online (Sandbox Code Playgroud)
这是我对Hicon的css,其他3个元素的css大致相同:
#Hicon0, #Hicon1, #Hicon2, #Hicon3, #Hicon4, #Hicon5, #Hicon6, #Hicon7, #Hicon8, #Hicon9, #Hicon10, #Hicon11 {
position: absolute;
top: 5%;
left: 1.4%; /* set in main.js */
width: 5.5%;
height: 40%;
}
Run Code Online (Sandbox Code Playgroud)
这里是Hicon的HTML,其他项目在hourlyforecast div中的格式相同.
<div id="hourlyforecastContainer" …Run Code Online (Sandbox Code Playgroud)