简体   繁体   English

我想在uitableview中添加第二列。 怎么样?

[英]I would like to add a second column to my uitableview. How?

I currently have a table view with one column and static information. 我目前有一个带有一列和静态信息的表视图。 I would like to add a second column with information that will updated from a server. 我想添加第二列,其中包含将从服务器更新的信息。

Here is my code right now: 现在是我的代码:

var array = ["Daskalakis Athletic Center" , "Hagerty Library", "Hans Dining Hall", "Northside Dining Hall", "Urban Eatery", "Creese Student Center", "Cyber Learning Center", "Rush Advisors"]

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
    return array.count
}

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

    cell.textLabel!.text = self.array[indexPath.row]

    return cell
}

As Eugene suggested, you may need to rewrite the implementation and need to use UICOllectionView instead of UITableView. 正如Eugene建议的那样,您可能需要重写实现并需要使用UICOllectionView而不是UITableView。

An alternate approach is, you design the cell in such a way that it looks like it have two coloumns (Reduce the cell content view width to half and replicate the same view and align it to other half, you can also add a vertical separator in between both). 另一种方法是,以这样的方式设计单元格,使其看起来像有两个列(将单元格内容视图的宽度减小到一半,然后复制相同的视图并将其对齐到另一半,还可以在其中添加垂直分隔符两者之间)。

You may use UICollectionView instead UITableView. 您可以使用UICollectionView代替UITableView。 Or you can use second UITableView. 或者,您可以使用第二个UITableView。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想在向UITableView添加新单元格时增加rowHeight - I would like to increase the rowHeight as I add new cells to UITableView iPhone UITableView。如何打开像音乐应用程序这样的单字母字母列表? - iPhone UITableView. How do turn on the single letter alphabetical list like the Music App? 如何设置UITableView的边框样式? 我希望它们圆润,有点斜面 - How can I style the borders of my UITableView? I would like them rounded and a little bit beveled UITableView内的UICollecionView。 如何处理选择? - UICollecionView inside UITableView. How to handle selections? 如何将UITableViewCell放到UITableView的底部。 - How to drop UITableViewCell to bottom of UITableView. UITableView内部的UIView的CA动画。 就像iTunes上的那个一样 - CA animation of a UIView inside a UITableView. Like the one on iTunes 如何为我的应用创建这样的“关于”页面? 如何在UIView下拥有UITableView(分组)? - How would I create an “About” page like this for my app? How do I have a UITableView (grouped) under a UIView? iOS:UISearchDisplayController和UITableView。 - IOS: UISearchDisplayController and UITableView. 如何在uiTableView中为每个单元格设置不同的图像。 - How to set different images for every cell in uiTableView.? UITableViewCell 中的平移手势可防止在 UITableView 中滚动。 如何解决? - Pan gesture in UITableViewCell prevents scrolling in UITableView. How to fix it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM