【问题标题】:How to customise UITableView如何自定义 UITableView
【发布时间】:2012-09-11 15:57:50
【问题描述】:

实际上我正在尝试在 UITableView 的不同行中实现不同的图像。 通过创建一个新的 UITableViewCell 我尝试了很多来实现它但我失败了。我需要在每一行中设置两个图像和一个标签。 如何做呢? 而且我必须使用导航控制器在下一页中获取图像... 请指定我的代码并解释。否则我无法理解。 感谢您提供信息丰富的答案...

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 5;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";

        sampletable1 *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {

            NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"sampletable1" owner:nil options:nil];
            for (UIView *view in views) {
                if([view isKindOfClass:[UITableViewCell class]])
                {
                    cell = (sampletable1*)view;


                }
            }
        }

【问题讨论】:

  • 您将要放入标签的图像和文本保存在哪里?您要设置sampletable1 对象中的哪些属性?
  • 我创建了一个名为 images 的组。并且sampletable1中没有添加任何属性。
  • 我不知道你所说的“组”是什么意思。如果您的自定义单元格没有任何属性,那么它有什么

标签: xcode4 uitableview


【解决方案1】:

这是您需要的。Subclassing UITableViewCell。显示的示例中有两个图像。您可以使用相同的技术再添加一个

【讨论】:

  • 其实我没有使用故事板应用程序
  • “链接器命令失败,退出代码为 1(使用 -v 查看调用)”究竟是什么意思?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-09
相关资源
最近更新 更多