【发布时间】: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