我有一个带表的视图控制器。第一次创建并显示单元格时,将按顺序调用以下功能(除了视图控制器功能外):
....
func viewWillAppear(_ animated: Bool)
func cellForRow(at indexPath: IndexPath) -> UITableViewCell?
optional func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
func viewWillDisappear(_ animated: Bool)
....
当我退出屏幕an时,将调用以下功能。
....
func viewWillAppear(_ animated: Bool)
func viewWillDisappear(_ animated: Bool)
....
但是为什么在willDisplaycell
和viewWillAppear
之间没有调用viewWillDisappear
?
日志为:
viewWillAppear
cellForRowAtIndexPath: 0
willDisplayCell: 0
cellForRowAtIndexPath: 1
willDisplayCell: 1
cellForRowAtIndexPath: 2
willDisplayCell: 2
viewWillDisappear
viewWillAppear
viewWillDisappear
代替:
viewWillAppear
cellForRowAtIndexPath: 0
willDisplayCell: 0
cellForRowAtIndexPath: 1
willDisplayCell: 1
cellForRowAtIndexPath: 2
willDisplayCell: 2
viewWillDisappear
viewWillAppear
willDisplayCell: 0
willDisplayCell: 1
willDisplayCell: 2
viewWillDisappear
答案 0 :(得分:0)
我最终要做的是检查viewDidAppear中显示了哪些单元格。不确定这是最好的答案,所以不要犹豫,添加更好的答案。
INSERT INTO contacts (id, data)
VALUES ({uuid} :: {dataObject} jsonb)
ON CONFLICT (
(data->>'customerId'),
LOWER(COALESCE(data->'data'->'profile'->'location'->>'formatted', '')),
LOWER(COALESCE(data->'data'->'profile'->'name'->'anglican'->>'given', '')),
LOWER(COALESCE(data->'data'->'profile'->'name'->'anglican'->>'middlename', '')),
LOWER(COALESCE(data->'data'->'profile'->'name'->'anglican'->>'surname', '')),
LOWER(COALESCE(data->'data'->'profile'->'name'->'anglican'->>'suffix', '')),
LOWER(COALESCE(data->'data'->'profile'->'name'->'anglican'->>'title', ''))
)
WHERE deleted = false and duplicated = false
DO UPDATE
SET data =
jsonb_build_object(
'id', contacts.id,
'data', jsonb_build_object(
'fields',(contacts.data->'data'->>'fields')::jsonb || (excluded.data->'data'->>'fields')::jsonb,
'profile',(excluded.data->'data'->>'profile')::jsonb,
'status',contacts.data->'data'->>'status',
'contacted',contacts.data->'data'->>'contacted',
'successful',contacts.data->'data'->>'successful',
'reservation',(contacts.data->'data'->>'reservation')::jsonb
),
'meta', jsonb_build_object(
'etag',contacts.data->'meta'->>'etag',
'created',contacts.data->'meta'->>'created',
'modified',excluded.data->'meta'->>'modified',
'resource',contacts.data->'meta'->>'resource',
'createdBy',contacts.data->'meta'->>'createdBy',
'isDeleted',contacts.data-> 'meta'->>'isDeleted',
'modifiedBy',excluded.data->'meta'->>'modifiedBy'
),
'customerId',contacts.data->>'customerId',
'securityGroupId',contacts.data->>'securityGroupId'
)
RETURNING *;