你必須創建自己的UITableVIewCellSubclass,這並不像你想象的那麼難。
基本上你只需要在分隔符之間添加2個UITextField和一個UIImageView。
我建議你看看蘋果的TableView編程指南,特別是A Closer Look at Table-View Cells
你有一個代碼示例非常相似,你想達到的目標。這裏是思想(未測試的代碼):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ImageOnRightCell";
UITextField*main, *second;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
main = [[[UITextField alloc] initWithFrame:CGRectMake(0.0, 0.0, 220.0, 15.0)] autorelease];
main.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:main];
second = [[[UITextField alloc] initWithFrame:CGRectMake(220.0, 0.0, 220.0, 15.0)] autorelease];
second.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:second];
}
return cell;
}
希望這有助於 文森特
你能分解你的想法嗎? – user501836