Swift 带有Appcelerator超循环的自定义TableViewCell

Swift 带有Appcelerator超循环的自定义TableViewCell,swift,appcelerator,appcelerator-titanium,appcelerator-hyperloop,hyperloop,Swift,Appcelerator,Appcelerator Titanium,Appcelerator Hyperloop,Hyperloop,Hi希望使用hyperloop创建自定义tableViewCell。问题是,我不知道该怎么做。我已尝试使用swift类实现它: 斯威夫特 import UIKit public class MyCell: UITableViewCell{//UICollectionViewCell { public var imgUser:UIImageView = UIImageView() public var labUerName:UILabel = UILabel() pub

Hi希望使用hyperloop创建自定义tableViewCell。问题是,我不知道该怎么做。我已尝试使用swift类实现它:

斯威夫特

import UIKit

public class MyCell: UITableViewCell{//UICollectionViewCell {

    public var imgUser:UIImageView = UIImageView()
    public var labUerName:UILabel = UILabel()
    public var labMessage:UILabel = UILabel()
    public var labTime:UILabel = UILabel()

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        NSLog("la");
        imgUser.backgroundColor = UIColor.blue

        imgUser.translatesAutoresizingMaskIntoConstraints = false
        labUerName.translatesAutoresizingMaskIntoConstraints = false
        labMessage.translatesAutoresizingMaskIntoConstraints = false
        labTime.translatesAutoresizingMaskIntoConstraints = false

        labUerName.frame = CGRect(x: 5, y: 5, width: 70, height: 30)

        contentView.addSubview(imgUser)
        contentView.addSubview(labUerName)
        contentView.addSubview(labMessage)
        contentView.addSubview(labTime)


    }

    public required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }


    public func setName(txt: String){
        labUerName.text = txt
    }


}
在我的选项卡视图控制器中:

(function (container) {

    var UIScreen = require('UIKit/UIScreen'),
        UIColor = require('UIKit/UIColor'),
        UITableView = require('UIKit/UITableView'),
        UITableViewCell = require('UIKit/UITableViewCell'),
        NSIndexPath = require('Foundation').NSIndexPath,
        UITableViewStyleGrouped = require('UIKit').UITableViewStyleGrouped,
        UITableViewCellStyleSubtitle = require('UIKit').UITableViewCellStyleSubtitle,
        UITableViewCellAccessoryDisclosureIndicator = require('UIKit').UITableViewCellAccessoryDisclosureIndicator;

    // Grabs the JSON-file from app/lib/static/data.json 
    var file = Ti.Filesystem.getFile(Ti.Filesystem.getResourcesDirectory() + 'static/data.json'); 
    var users = JSON.parse(file.read().text).users;
    var Cell = require('MyFramework/MyCell'); // HERE IS MY CUSTOM CELL

    // Subclass delegate + data source
    var TableViewDataSourceAndDelegate = require('subclasses/tableviewdatasourcedelegate');

    // Create + configure tableView
    var tableView = UITableView.alloc().initWithFrameStyle(UIScreen.mainScreen.bounds, UITableViewStyleGrouped);
    var dataSourceDelegate = new TableViewDataSourceAndDelegate();

    dataSourceDelegate.numberOfSections = function(tableView) {
        return 1;
    };
    dataSourceDelegate.numberOfRows = function(tableView, section) {
        return users.length;
    };
    dataSourceDelegate.titleForHeader = function(tableView, section) {
        return 'Available users: ' + users.length;
    };
    dataSourceDelegate.heightForRow = function(tableView, indexPath) {
        return 44;
    };
    dataSourceDelegate.cellForRow = function(tableView, indexPath) {

        var user = users[indexPath.row];


        var cell = tableView.dequeueReusableCellWithIdentifierForIndexPath('hyperloop_cell', indexPath);



        cell.setName('abc');

        return cell;
    };
    dataSourceDelegate.didSelectRowAtIndexPath = function(tableView, indexPath) {       
        alert('Call me maybe: ' + users[indexPath.row].phone);
        tableView.deselectRowAtIndexPathAnimated(indexPath, true);
    };


    // Assign delegate + data source
    tableView.registerClassForCellReuseIdentifier(Cell.self, "hyperloop_cell");
    tableView.setDelegate(dataSourceDelegate);
    tableView.setDataSource(dataSourceDelegate);

    container.add(tableView);

})($.tableview_container);
我不知道如何使用它。有人能帮我吗?
谢谢

我不知道为什么它不起作用,但是你似乎没有做任何没有超循环就做不到的事情。。。为什么不使用Appcelerator创建您自己的tableview单元格/行布局?

不确定为什么它不工作,但是看起来您没有做任何没有hyperloop无法完成的事情。。。为什么不使用Appcelerator创建自己的tableview单元格/行布局?

我已经尝试用JS创建了它。我不知道该怎么做。这就是为什么我尝试使用swift的原因。看起来它应该是有能力的,所以也许你只需要温习一下文档?或者发布你想要的行的样子,也许可以帮助你指出正确的方向。经过多次尝试,问题似乎是我的swift类。我清空了里面所有的东西,一切正常。。。我将继续以那种方式搜索,我已经在JS中尝试过了。我不知道该怎么做。这就是为什么我尝试使用swift的原因。看起来它应该是有能力的,所以也许你只需要温习一下文档?或者发布你想要的行的样子,也许可以帮助你指出正确的方向。经过多次尝试,问题似乎是我的swift类。我清空了里面所有的东西,一切正常。。。我将继续以这种方式进行搜索