1

ハイパーループを使用してカスタムtableViewCellを作成したいと考えています。問題は、私は方法を理解していないということです。Appceleratorハイパーループを使用したカスタムTableViewCell

Cell.swift私tabbleviewコントローラで

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); 

私は迅速クラスでそれを実装しようとしました。誰かが私を助けることができますか? ありがとう

答えて

0

なぜそれがうまくいかないのか分かりませんが、ハイパーループなしではできないことは何もしていないようです... Appceleratorで独自のテーブルビューセル/行レイアウトを作成するだけではどうですか?

+0

私はJSでそれをしようとしました。私はそれをする方法を理解していませんでした。だからこそ私は迅速に試しました。 –

+0

それは有能であるはずだと思われますので、多分ドキュメントをブラシする必要がありますか?または、あなたが行を見たいと思っているものを投稿したり、正しい方向に向けるのを助けることができます。 – Ray

+0

多くの試みの後、問題は私の迅速なクラスと思われる。私はそれのすべてのものを空にして正常に動作します...私はそのように検索を続けます –