简体   繁体   English

iOS UITableViewController单元格数据填充

[英]iOS UITableViewController cells data filling

Two questions: 两个问题:

  1. I am trying to build a app that has a table view. 我正在尝试构建一个具有表视图的应用程序。 I would like the user to click on a topic and then the next table view has a image on the left and text on the right. 我希望用户单击一个主题,然后下一个表格视图的图像在左侧,文本在右侧。 Does anyone know any sample code that would help me accomplish this? 有谁知道任何示例代码可以帮助我实现这一目标?

    Example: 例:

    iPad --> WiFi, and WiFi + 3G iPad-> WiFi和WiFi + 3G
    iPhone --> AT&T, Verizon iPhone-> AT&T,Verizon

  2. Also is their a way to tag images in xCode? 它们也是在xCode中标记图像的方法吗? So in my table view I can only pull images with tag "x"? 因此,在我的表格视图中,我只能提取带有标签“ x”的图像吗?

Check out http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html for sample code on how to implement table views. 请访问http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html,以获取有关如何实现表格视图的示例代码。

I don't understand your question about tagging. 我不了解您有关标记的问题。 You can use [UIImage imageNamed:] to pull in images that are bundled in your app. 您可以使用[UIImage imageNamed:]提取应用程序中捆绑的图像。 Name them as you will. 随便命名。

See Dispelling the UIImage imageNamed: FUD for a discussion of this method. 有关此方法的讨论,请参见消除UIImage imageNamed:FUD

First of all make a navigation based app. 首先制作一个基于导航的应用程序。 This gives you an app with a view controller in place with a table view on the screen. 这为您提供了一个带有视图控制器的应用程序,并且在屏幕上具有表格视图。

Take a look at these for more info: 看看这些以获得更多信息:

UITableViewController Class Reference UITableViewController类参考

UITableViewCell Class Reference UITableViewCell类参考

In this last one take a look at initWithStyle:reuseIdentifier: , this will allow you to use the style you need, if you have default and add a picture to this cell it will show in the left side, pushing the text a little to the right. 在最后一个中,查看initWithStyle:reuseIdentifier:这将允许您使用所需的样式,如果您具有默认样式并将图片添加到此单元格中,它将显示在左侧,将文本稍微向后推。对。

For tagging an image you can simply do 要标记图像,您只需
image.tag = tagNumber;
For the cell image you can have like this: 对于单元格图像,您可以像这样:
image.tag = tagNumber;
cell.imageView.image = image;

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM