好的,经过几次尝试后,我终于在 @jrturton (how to populate a static UITableView)的帮助下填充了静态表视图。
但是现在我还有另外一个问题..在填充字段时,只有可见字段通过我使用的方法填充。通过代码填充的其他字段在向下滚动时保持为空。
有什么我想念的吗?虽然通过委托填充动态表肯定会解决我看到的问题,但我不想通过数组等填充所有静态文本(标签)。我知道表中总会有16行。
所以任何人都对出了什么问题有任何建议?
以下是代码:
- (void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
}
}
-(void)setParam:(id)newparam
{
if (_param != newparam) {
_param = newparam;
// Update the view.
[self configureView];
}
if (self.masterPopoverController != nil) {
[self.masterPopoverController dismissPopoverAnimated:YES];
}
}
- (void)configureView
{
// Update the user interface for the detail item.
if (_detailItem) {
for (int idx=0; idx<16; idx++) {
NSString *value = [NSString stringWithFormat:@"%@",[_param objectAtIndex:idx]];
[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:idx inSection:0]].detailTextLabel.text = value;
}
}
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Do any additional setup after loading the view, typically from a nib.
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[self configureView];
}
我修改了早期代码中的一些行,并添加了一些可能有助于更好理解的代码。