我正在尝试在Swift中创建一个WebView,并在class AppDelegate: UIResponder, UIApplicationDelegate {
行上获取错误代码“Thread 1:signal SIGABRT”
我的代码如下(变量“theURL”确实有一个真实的URL):
import UIKit
class ViewController: UIViewController {
@IBOutlet var Webview: UIWebView!
var theURL = "URL"
func loadWebPage() {
let theRequestURL = NSURL (string: theURL)
let theRequest = NSURLRequest(URL: theRequestURL!)
Webview.loadRequest(theRequest)
}
override func viewDidLoad() {
super.viewDidLoad()
loadWebPage()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
提前致谢!
答案 0 :(得分:0)
您必须将此页面链接到Main.Storyboard。您可以使用Main.Storyboard中的Web View。
答案 1 :(得分:0)
其中一个原因 -
if let theRequestURL = NSURL (string: theURL) { let theRequest = NSURLRequest(URL: theRequestURL!) Webview.loadRequest(theRequest) }
答案 2 :(得分:0)
我理解这个问题是从一段时间以来我只是遇到了完全相同的问题,我通过检查main.storyboard文件中的插座连接解决了这个问题。我从代码中删除了一个插座,但没有从main.storyboard删除。点击所有视图并检查他们的插座连接。
答案 3 :(得分:0)
我希望这可以解决问题:)
while True:
if args.connect:
server_socket.send(bytes(" success ".join([args.interface, args.device]), 'utf-8'))
recived_response=server_socket.recv(1048)
d_rec= recived_response.decode("utf-8")
msg_array=d_rec.split(" ")
if 'connect' in msg_array:
connect(relayboards.get(devices[args.device][args.interface].get("board")) ,int(PORT))
digital_command(args.device, args.interface, "connect")
print("ready to connect...%s" % d_rec)
print("~~CONNECTED~~")
#server_socket.close()
break
else:
continue
#print("oops")
elif args.disconnect:
connect(relayboards.get(devices[args.device][args.interface].get("board")) ,int(PORT))
server_socket.send(bytes(" failure ".join([args.interface, args.device]), 'utf-8'))
if server_socket.recv(30)== b'disconnect':
digital_command(args.device, args.interface, "disconnect")
print("~~DISCONNECTED~~")
#server_socket.close()
break
else:
print("the device was not connected at the first place")
#server_socket.close()
break
请参阅此链接: https://developer.apple.com/documentation/webkit/wkwebview#2560973