我正在尝试使用Table构建一个简单的WatchKit应用程序。每行都有一个Label。这是我的TableRowController类:
"use strict";
var webpack = require('webpack');
var loaders = require('./webpack.loaders');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const HOST = process.env.HOST || "127.0.0.1";
const PORT = process.env.PORT || "8888";
// global css
loaders.push({
test: /[\/\\](node_modules|global)[\/\\].*\.css$/,
loaders: [
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'style?sourceMap',
'css'
]
});
//local sass modules
loaders.push({
test: /[\/\\]src[\/\\].*\.sass/,
loaders: [
'style?sourceMap',
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'sass'
]
});
//local css modules
loaders.push({
test: /[\/\\]src[\/\\].*\.css/,
loaders: [
'style?sourceMap',
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
]
});
module.exports = {
entry: [
`webpack-dev-server/client?http://${HOST}:${PORT}`,
`webpack/hot/only-dev-server`,
`./src/index.jsx` // Your appʼs entry point
],
devtool: process.env.WEBPACK_DEVTOOL || 'cheap-module-source-map',
output: {
path:__dirname,
filename: './src/bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders
},
devServer: {
// do not print bundle build stats
noInfo: true,
// enable HMR
hot: true,
// embed the webpack-dev-server runtime into the bundle
inline: true,
// serve index.html in place of 404 responses to allow HTML5 history
historyApiFallback: true,
port: PORT,
host: HOST
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
]
};
在我的InterfaceController中,我向表中添加一行并尝试设置Label的文本。但是,taskList.rowController(at:0)找不到行,因此Label未经修改。
import WatchKit
class TaskTableRowController: NSObject {
@IBOutlet var taskName: WKInterfaceLabel!
}
答案 0 :(得分:0)
替换以下代码,它适用于我:
taskList.setNumberOfRows(10, withRowType: "TaskRow")
for index in 0..<taskList.numberOfRows {
if let controller = taskList.rowControllerAtIndex(index) as? TaskTableRowController {
controller.taskName.setText("Hello World")
}
}
我看过屏幕截图但是pl。交叉检查&amp;请确保以下几点:
WKInterfaceLabel
(taskName)您的IBOutlet
TaskTableRowController
。
TaskTableRowController
标识符
到'TaskRow'。
WKInterfaceTable
(taskList)有一个IBOutlet。
设置了'TaskTableRowController'行的自定义类。
希望它可以帮助你!!!
如果您有任何疑问,请与我们联系。