2012-09-19 51 views
1

其实我试图在UITableView的不同行中实现不同的图像。 通过创建一个新的UITableViewCell我试了很多实现这个,但我失败了。我需要在每一行设置两个图像和一个标签。 怎么办? 我必须使用导航控制器在下一页中获取图像... 请指定我的代码和解释,否则我无法理解。 谢谢您的信息的答案...如何自定义UITableView

- (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; 


       } 
      } 
     } 
+0

您将图像和文本放在标签中的哪个位置?您想要设置的'sampletable1'对象中的属性是什么? –

+0

我已经创建了一个名为images的组。样本表1中没有添加任何属性。 – goku

+0

我不知道你是什么意思的“组”。如果您的自定义单元格没有任何属性,它具有哪些**? –

回答

0

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

+0

实际上,我没有使用故事板应用程序 – goku

+0

“linker命令失败,退出代码1(使用-v查看调用 )”实际上这意味着什么? – goku