[PR]
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
テーブルのセルへの参照を2種類以上混在させる
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"Cell"]autorelease];
}
PositionTableViewCell *pCell = (PositionTableViewCell *)[tableView
dequeueReusableCellWithIdentifier:@"PositionTableViewCell"];
if (pCell == nil) {
pCell = [[[PositionTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"PositionTableViewCell"] autorelease];
}
SwitchTableViewCell *sCell = (SwitchTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"SwitchTableViewCell"];
if (sCell == nil) {
sCell = [[[SwitchTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"SwitchTableViewCell"] autorelease];
}
switch (indexPath.row) {
case 0: {
sCell.selectionStyle = UITableViewCellSelectionStyleNone;
sCell.myDictionary = self.myDictionary;
sCell.editedKey = @"display";
[sCell.switchCtl setOn:[[myDictionary objectForKey:@"display"] boolValue]
animated:NO];
sCell.nomalLabel.text = NSLocalizedString(@"Display",@"");
return sCell;
break;
}
case 1: {
cell.font = [UIFont systemFontOfSize:20];
cell.text = [NSString stringWithFormat:NSLocalizedString(@"Name:
%@", @""),[myDictionary objectForKey:@"name"]];
return cell;
break;
}
case 2: {
pCell.enabledSetting = YES;
pCell.titleLabel.text = NSLocalizedString(@"Center",@"");
pCell.leftTitleLabel.text = @"X";
pCell.leftValueLabel.text = [NSString stringWithFormat:@"%f",
[[myDictionary objectForKey:@"centerx"]floatValue]];
pCell.centerTitleLabel.text = @"Y";
pCell.centerValueLabel.text = [NSString stringWithFormat:@"%f",
[[myDictionary objectForKey:@"centery"] floatValue]];
pCell.rightTitleLabel.text = @"Z";
pCell.rightValueLabel.text = [NSString stringWithFormat:@"%f",
[[myDictionary objectForKey:@"centerz"] floatValue]];
return pCell;
break;
}
case 3: {
pCell.enabledSetting = YES;
pCell.titleLabel.text = NSLocalizedString(@"Rotate",@"");
pCell.leftTitleLabel.text = @"X";
pCell.leftValueLabel.text = [NSString stringWithFormat:@"%f",
[[myDictionary objectForKey:@"rotatex"] floatValue]];
pCell.centerTitleLabel.text = @"Y";
pCell.centerValueLabel.text = [NSString stringWithFormat:@"%f",
[[myDictionary objectForKey:@"rotatey"] floatValue]];
pCell.rightTitleLabel.text = @"Z";
pCell.rightValueLabel.text = [NSString stringWithFormat:@"%f",
[[myDictionary objectForKey:@"rotatez"] floatValue]];
return pCell;
break;
}
case 4: {
cell.font = [UIFont systemFontOfSize:20];
if ([myDictionary objectForKey:@"magnification"] == nil) {
[myDictionary setObject:[NSNumber numberWithFloat:1]
forKey:@"magnification"];
}
cell.text = [NSString stringWithFormat: NSLocalizedString (
@"Magnification: %f",@""),[[myDictionary objectForKey:
@"magnification"]floatValue]];
return cell;
break;
}
}
return cell;
}