我目前正处理涉及OS X App审核小组的两难问题。对于我自己,我的团队以及我所有的beta测试人员来说,屏幕都应该出现了:
然而,App Review团队回来了:
2.3
The app does not achieve the core functionality described in your marketing materials or release notes.
The app launches with black window and no UI is loaded. Screenshot is attached for your reference.
有什么想法吗?该应用程序是一个简单的WebView。不知道为什么它只会对他们起作用。
ViewController.swift
import Cocoa
import WebKit
import Foundation
let secureURL = "https://www.arcsoft.io/"
class ViewController: NSViewController {
@IBOutlet weak var webView: WebView!
@IBOutlet weak var windowTitle: NSTextField!
@IBOutlet weak var networkError: NSImageView!
@IBOutlet weak var retryButton: NSButton!
@IBAction func attemptReload(sender: NSButton) {
self.webView.mainFrame.loadRequest(NSURLRequest(URL: NSURL(string: secureURL)!))
}
let defaults = NSUserDefaults.standardUserDefaults()
override func viewDidLoad() {
super.viewDidLoad()
// Initial WebView Setup
webView.layerUsesCoreImageFilters = true
WebPreferences.standardPreferences().allowsAirPlayForMediaPlayback = true
// Client Identifier
let userAgent = "ARCSOFT Client v1.0"
webView.customUserAgent = userAgent
defaults.registerDefaults(["UserAgent": userAgent])
defaults.registerDefaults(["User-Agent": userAgent])
// Launch Secure Client
self.webView.mainFrame.loadRequest(NSURLRequest(URL: NSURL(string: secureURL)!))
// Hide Network Error on Launch
retryButton.hidden = true
networkError.hidden = true
}
func webView(sender: WebView!, didReceiveTitle title: String!, forFrame frame: WebFrame!) {
windowTitle.stringValue = "ARCSOFT™ – Web Builder & Design"
}
func webView(sender: WebView!, didFinishLoadForFrame frame: WebFrame!) {
print("Load Successful")
retryButton.hidden = true
networkError.hidden = true
}
func webView(sender: WebView!, didStartProvisionalLoadForFrame frame: WebFrame!) {
retryButton.hidden = true
networkError.hidden = true
}
func webView(sender: WebView!, didFailProvisionalLoadWithError error: NSError!, forFrame frame: WebFrame!) {
print("Failed to Load Client")
// Present user with error.
retryButton.hidden = false
networkError.hidden = false
networkError.layer?.backgroundColor = NSColor(red:0.145, green:0.145, blue:0.157, alpha:1.0).CGColor
}
func webView(sender: WebView!, runOpenPanelForFileButtonWithResultListener resultListener: WebOpenPanelResultListener!, allowMultipleFiles: Bool) {
let openDialog = NSOpenPanel()
if (openDialog.runModal() == NSModalResponseOK) {
let fileName: String = (openDialog.URL?.path)!
resultListener.chooseFilename(fileName) // Use chooseFilenames for multiple files
}
}
override var representedObject: AnyObject? {
didSet {
// Update the view, if already loaded.
}
}
}
WindowViewController.swift
import Cocoa
class WindowViewController: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad()
window!.titlebarAppearsTransparent = true
window!.movableByWindowBackground = true
window!.title = ""
window!.backgroundColor = NSColor(red:0.11, green:0.16, blue:0.20, alpha:1.0)
}
}
答案 0 :(得分:0)
当我在Mac上的Safari中转到https://www.arcsoft.io/时,在所有内容出现之前,我也会看到一两秒钟的完全空白屏幕。在UI的其余部分出现之前,您的请求可能会超时(或者审核人员没有等待很长时间)。也许你需要一段时间,但因为你已经习惯了它,你不会注意到它。无论哪种方式,您的应用都应该通过减少网页的加载时间和/或在网页加载时在应用上显示某些来提高响应速度。
答案 1 :(得分:0)
为了正常工作,您的代码应该实现一些功能。需要使用正确的delegate
(示例中的代码目前完全依赖于webView
加载才能显示任何内容。有人看到完全空白屏幕的原因是因为如果没有互联网连接,则会加载空webView
。此外,由于您还没有包含WebFrameLoadDelegate
,因此定义的方法绝对没有任何内容。
在ViewController中实现了这一功能后,您可以将IB中的frameLoad
Outlet连接到webView
,方法应该能够正确处理。