一切正常,除了我试图tableView在实时视图中显示的最后一行不起作用:PlaygroundPage.current.liveView = controller
我无法弄清楚我错了什么?
import UIKit
import PlaygroundSupport
import Foundation
class TableViewController: UITableViewController {
let tableData = ["Matthew", "Mark", "Luke", "John"]
override func viewDidLoad() {
super.viewDidLoad()
print("Hello Matt")
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableData.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell
cell.textLabel?.text = tableData[indexPath.row] …Run Code Online (Sandbox Code Playgroud) 有没有办法以WatchKit Table Row编程方式设置颜色?
在我的应用程序的iPhone部分,我设置每个具体Table Cell:
cell.backgroundColor = [self colorWithHexString:[stringArrayColor objectAtIndex:indexPath.row]];
Run Code Online (Sandbox Code Playgroud)
所以基本上尝试设置每种类型的行的背景颜色:

我不敢didReceiveApplicationContext打电话。有任何想法吗?
InterfaceController:
import WatchKit
import Foundation
import WatchConnectivity
class InterfaceController: WKInterfaceController, WCSessionDelegate {
@IBOutlet var colorLabel: WKInterfaceLabel!
private let session: WCSession? = WCSession.isSupported() ? WCSession.defaultSession() : nil
override init() {
super.init()
session?.delegate = self
session?.activateSession()
}
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
}
func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]){
let colors : String = applicationContext["color"] as! String
colorLabel.setText(colors)
NSLog("session did receive application context")
}
}
Run Code Online (Sandbox Code Playgroud)
我一直在跟随本教程:http : //www.kristinathai.com/watchos-2-how-to-communicate-between-devices-using-watch-connectivity/
否NSLog或colorLabel …
我Parse在我的iPhone应用程序中进行查询,但是在尝试Parse在我的Watch应用程序中执行相同的查询时遇到错误.
这是我的iPhone应用程序中的查询:
- (void)viewDidLoad {
// GMT Date from Phone
NSDate *gmtNow = [NSDate date];
NSLog(@"GMT Now: %@", gmtNow);
// Query Parse
PFQuery *query = [self queryForTable];
[query whereKey:@"dateGame" greaterThanOrEqualTo:gmtNow];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSMutableArray *localMatchup = [@[] mutableCopy];
for (PFObject *object in objects) {
// Add objects to local Arrays
[localMatchup addObject:[object objectForKey:@"matchup"]];
// App Group
NSString *container = @"group.com.me.off";
NSUserDefaults *defaults …Run Code Online (Sandbox Code Playgroud) ios ×4
watchkit ×4
swift ×3
objective-c ×2
iphone ×1
tablerow ×1
uitableview ×1
watchos-2 ×1
xcode7 ×1