編集可能なtableHeaderViewにUITableView("連絡先"アプリ)
-
20-09-2019 - |
質問
っていうのを実施する編集可能の詳細ビューをグループ化UITableView.思うように見えるのは、連絡先申し込み:
- 視聴状態での表示ヘッダーをプレーンラベル(連絡先の名前の透明にします
- 編集状態になるヘッダを表示して編集可能なUITableViewCell(連絡先のtableHeader?変化からのテキストの透明背景に標準UITableViewCellを白にします
私はいま何をするのが最善だと思います、これを達成する。第たって追加のヘッダとしてUILabel tableHeaderViewる作品が大きい)ものの、その後の切り替えができませんことをUITableViewCell.る可能性が除去のヘッダを追加するときには入力編集モードに切り替えます。
現在のようにしているため、常に使用UITableViewCellで透明性の視聴モードに切り替えることでデフォルトでは編集モードに切り替えます。しかし、続いていることができUILabelのUITableViewCellをはUITableViewCellStyleDefault)透明(あかしをしているUITableViewCell透明なのtextLabel内です。
何が最良の方法の実用的に振る舞えるのでしょうか?
解決
私は私のソリューションはisEditing
に基づいてそれらの間に2つの異なるヘッダビューやスイッチを使用しています(!iOS4をで連絡先アプリへの変更と論点が)あまりにもこれをやった。
- (UIView *)infoHeaderAnimated:(BOOL)animated {
UIView *header = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 90.0)] autorelease];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(98.0, 41.0, 221.0, 21.0)];
label.font = [UIFont boldSystemFontOfSize:17.0];
label.backgroundColor = [UIColor clearColor];
label.text = baseEntity.labelText;
[header addSubview:label];
[label release];
return header;
}
- (UIView *)editingHeaderAnimated:(BOOL)animated {
UIView *header = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 90.0)] autorelease];
UITableView *tv = [[UITableView alloc] initWithFrame:CGRectMake(78.0, 10.0, 240.0, 90.0) style:UITableViewStyleGrouped];
tv.backgroundColor = [UIColor clearColor];
tv.dataSource = self;
tv.delegate = self;
tv.rowHeight = 62.0; //@@@ height of cell and frame depend on elements
tv.tag = kEditingHeaderTag;
editingHeaderTableView = [tv retain];
[header addSubview:tv];
[tv release];
return header;
}
他のヒント
非常に標準で何をしようとしている、UITableViewDatasourceでこれらのプロトコル、特にtitleForHeaderInSection&commitEditingStyleの実装を検討します:
Configuring a Table View
– tableView:cellForRowAtIndexPath: required method
– numberOfSectionsInTableView:
– tableView:numberOfRowsInSection: required method
– sectionIndexTitlesForTableView:
– tableView:sectionForSectionIndexTitle:atIndex:
– tableView:titleForHeaderInSection:
– tableView:titleForFooterInSection:
Inserting or Deleting Table Rows
– tableView:commitEditingStyle:forRowAtIndexPath:
– tableView:canEditRowAtIndexPath:
Interface Builderで代わりに平野のグループとして、あなたのテーブルビューのタイプを選択することを忘れないでください。
所属していません StackOverflow