如何自定义UITableView

时间:2012-09-19 10:41:20

标签: xcode4 uitableview

实际上我正试图在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;


                }
            }
        }

1 个答案:

答案 0 :(得分:0)

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