[英]How to create UITableViewCell like iphone Contact Address Cell?
我需要幫助來弄清楚如何在iphone通訊錄應用中創建一個類似於表示地址的單元格。 我不想創建一個地址。 我只需要知道如何在編輯模式下顯示以下內容:
非常感謝任何示例代碼,Apple示例(盡管我找不到),教程或一般指導。 我試圖避免創建自定義容器類來處理左側的所有內容,並根據我想放在右側的內容動態調整大小。 肯定有人已經這樣做了,對吧? :)
編輯模式如下所示:
您必須創建自己的UITableVIewCellSubclass,這並不像您想的那樣困難。
基本上,您只需要在其中添加2個UITextField和一個UIImageView作為分隔符即可。
我建議您看一下Apple的TableView編程指南,尤其是對Table-View單元格的仔細研究
您的代碼示例與您要實現的代碼非常相似。 這是想法(未經測試的代碼):
- (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;
}
希望對您有幫助,文森特
我只是做了這樣的事情。 我的解決方案非常特定於我的數據,但總的來說,這就是我的方法:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.