小编SRM*_*RMR的帖子

在Swift Playgrounds for iPad中显示TableView

一切正常,除了我试图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)

uitableview ios swift swift-playground

3
推荐指数
1
解决办法
985
查看次数

Watchogram表行背景颜色以编程方式

有没有办法以WatchKit Table Row编程方式设置颜色?

在我的应用程序的iPhone部分,我设置每个具体Table Cell:

cell.backgroundColor = [self colorWithHexString:[stringArrayColor objectAtIndex:indexPath.row]];
Run Code Online (Sandbox Code Playgroud)

所以基本上尝试设置每种类型的行的背景颜色:

在此输入图像描述

objective-c tablerow ios watchkit

2
推荐指数
1
解决办法
2325
查看次数

WatchKit didReceiveApplicationContext没有被调用

不敢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/

NSLogcolorLabel …

swift watchkit xcode7 watchos-2

2
推荐指数
2
解决办法
2721
查看次数

设置WKInterfacePicker颜色(文本或大纲)

有谁知道如何设置文本颜色或焦点样式轮廓颜色WKInterfacePicker

我没有看到Interface Builder,我无法在代码中找到任何可以设置它的属性项.

这是IB:

在此输入图像描述

ios swift watchkit

2
推荐指数
1
解决办法
842
查看次数

在WatchKit中解析查询

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)

iphone objective-c ios parse-platform watchkit

1
推荐指数
1
解决办法
2597
查看次数