我创建了一个应用程序,效果很好。奇怪的是,当我切换到应用程序后,我切换了手表充电,但是应用程序没有响应或在长时间延迟后响应导航。
我从设备日志中得知的最好的是应用程序到达前台但不响应导航命令,它似乎进入后台,但也许这是正常的调度?
...
Dec 9 11:10:10 Jims-AppleWatch iap2d[213] <Warning>: process com.ijaz.iInteract.watchkitapp.watchkitextension is now running the foreground
Dec 9 11:10:11 Jims-AppleWatch iap2d[213] <Warning>: process com.ijaz.iInteract.watchkitapp is now suspending
...
杀死应用程序并重新启动后,行为更符合我的预期,一旦启动它就不会暂停:
Dec 9 11:10:18 Jims-AppleWatch iap2d[213] <Warning>: process com.ijaz.iInteract.watchkitapp is now running the foreground
Dec 9 11:10:18 Jims-AppleWatch iap2d[213] <Warning>: process com.ijaz.iInteract.watchkitapp.watchkitextension is now running the foreground
Dec 9 11:10:26 Jims-AppleWatch Carousel[96] <Notice>: (Note ) log.facility.voicetrigger: ::: Received request to DISABLE voice trigger - Reason: Backlight turned on)
Dec 9 11:10:31 Jims-AppleWatch sharingd[26] <Error>: 11:10:31.383 : Failed to get taskInfo for Task <com.apple.nanoweatherd|B7795F05-2BDE-4896-9428-59A9442918BF>.<1>, replyMessage (null)
Dec 9 11:10:42 Jims-AppleWatch timed[33] <Notice>: (Note ) CoreTime: Received time 12/09/2015 19:10:41±0.01 from "TMLSSourceComputed"
Dec 9 11:10:42 Jims-AppleWatch timed[33] <Notice>: (Note ) CoreTime: Want active time in 139.59min. Need active time in 217.71min. Remaining retry interval: 0.000000min.
Dec 9 11:10:42 Jims-AppleWatch UserEventAgent[22] <Error>: validateAndAddDefaults(com.apple.timed): End Time (inf) > now (471381042.7) + BACKGROUND_TASK_AGENT_JOB_WINDOW_MAX_TIME_FROM_NOW_SEC (3024000.0) + BACKGROUND_TASK_AGENT_JOB_TIME_ERROR_MARGIN (300.0)
Dec 9 11:10:42 Jims-AppleWatch timed[33] <Notice>: (Note ) CoreTime: Received time 12/09/2015 19:10:42±0.00 from "TMLSSourceDevice"
Dec 9 11:10:42 Jims-AppleWatch timed[33] <Notice>: (Note ) CoreTime: Want active time in 139.58min. Need active time in 217.71min. Remaining retry interval: 0.000000min.
Dec 9 11:10:42 Jims-AppleWatch UserEventAgent[22] <Error>: validateAndAddDefaults(com.apple.timed): End Time (inf) > now (471381042.9) + BACKGROUND_TASK_AGENT_JOB_WINDOW_MAX_TIME_FROM_NOW_SEC (3024000.0) + BACKGROUND_TASK_AGENT_JOB_TIME_ERROR_MARGIN (300.0)
Dec 9 11:10:43 Jims-AppleWatch timed[33] <Notice>: (Error) CoreTime: Error requesting proactive time check job
今天我会尝试重现/今晚,但如果/当我这样做,我需要策略调试它。
以下是涉及的控制器:
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet var tableView:WKInterfaceTable!
var panels:[Panel] = [Panel]()
override func awakeWithContext(context: AnyObject?) {
panels = Panel.readFromPlist()
super.awakeWithContext(context)
}
override func willActivate() {
super.willActivate()
setupTable()
}
private func setupTable() {
var rowTypesList = [String]()
for _ in panels {
rowTypesList.append("PanelRow")
}
tableView.setRowTypes(rowTypesList)
for var i = 0; i < tableView.numberOfRows; i++ {
let panelRow = tableView.rowControllerAtIndex(i) as! PanelRow
let panel = panels[i]
panelRow.button.setTitle(panel.title)
panelRow.button.setBackgroundColor(panel.color)
}
}
override func contextForSegueWithIdentifier(segueIdentifier: String, inTable table: WKInterfaceTable, rowIndex: Int) -> AnyObject? {
return panels[rowIndex]
}
}
class PanelController: WKInterfaceController {
//Mark : Properties
@IBOutlet var PanelVerticalGroup: WKInterfaceGroup!
@IBOutlet var PanelTitle: WKInterfaceLabel!
@IBOutlet var Button1: WKInterfaceButton!
@IBOutlet var Button2: WKInterfaceButton!
@IBOutlet var Button3: WKInterfaceButton!
@IBOutlet var Button4: WKInterfaceButton!
var panel : Panel?
//Mark : Functions
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
let buttons = [self.Button1,self.Button2,self.Button3,self.Button4]
for button in buttons {
button.setHidden(true)
}
// Configure interface objects here.
self.panel = context as? Panel
PanelVerticalGroup.setBackgroundColor(panel!.color)
PanelTitle.setText(panel!.title + " ...")
PanelTitle.setTextColor(UIColor.blackColor())
var i = 0
for interaction in panel!.interactions {
let button = buttons[i++]
button.setHidden(false)
button.setBackgroundImage(interaction.picture)
}
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
override func contextForSegueWithIdentifier(segueIdentifier: String) -> AnyObject? {
let index = Int(segueIdentifier)
//return the interaction object so we can draw the button etc
let interaction = panel!.interactions[index!]
let color = panel!.color
let params : [AnyObject]? = [interaction,color]
return params
}
}