2014-10-02 65 views
-5

我在Xcode 6用客观的C代码的UITableView,但我想取代我的目标C代码迅速语言UITableView的使用迅速语言

+4

你在Swift代码上的尝试在哪里?这不是一个为您编写代码的网站。 – zaph 2014-10-02 12:09:59

+0

如果您在Swift中创建'UITableViewController'的子类,则大部分代码都会自动为您创建。还有@Zaph提到的,告诉我们你到目前为止所尝试过的,我们可以帮助你。 – Isuru 2014-10-02 12:13:41

+3

也许这将是学习Swift的好机会? – 2014-10-02 12:15:46

回答

1

复制并从默认UITableViewController子模板粘贴(文件>新建>文件> iOS版>源>可可触摸类>设置超到UITableViewController):

override func numberOfSectionsInTableView(tableView: UITableView!) -> Int { 
    // #warning Potentially incomplete method implementation. 
    // Return the number of sections. 
    return 0 
} 

override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { 
    // #warning Incomplete method implementation. 
    // Return the number of rows in the section. 
    return 0 
} 

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { 
    let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as UITableViewCell 

    // Configure the cell... 

    return cell 
} 

创建的UITableViewController在斯威夫特文件中的子类和代码适应您的需求。