ios - Why can't add UIView to UITableViewCell directly but contentView -


i never think question before may stupid.

[cell.contentview addsubview:xxxview]; 

and

[cell addsubview:xxxview]; 

apple said contentview should default superview contents. want know if bad if add subviews cell directly.

apple document:

the content view of uitableviewcell object default superview content displayed cell. if want customize cells adding additional views, should add them content view positioned appropriately cell transitions , out of editing mode.

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/tableview_iphone/tableviewcells/tableviewcells.html#//apple_ref/doc/uid/tp40007451-ch7-sw1

by default, editing control hidden until enter edit mode table in case, editing control appears (the minus button left of each row) , contentview gets resized , pushed right. gives "proper animation" effect.

to test difference, try adding subview such uilabel text, cell rather cell.contentview. when add cell rather cell.contentview , enter edit mode table, believe uilabel not resize, see edit button ontop/below minus sign button.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -