Reputation: 16189
I assigned a UIView
to a UITableViewCell's
accessoryView
then when i try to get the superView of it seems it's nil?
So does accessoryView
has a superview
? If no how does it appears?
Upvotes: 0
Views: 229
Reputation: 386008
A view cannot appear on screen unless it has a superview (or is itself a UIWindow
).
You may be checking the superview
property before it has been set. The accessory view is added as a subview of the cell by the cell's layoutSubviews
method. It doesn't happen immediately upon setting the cell's accessoryView
property.
If you replace an accessory view with another accessory view, the old accessory view will be removed from its superview (the cell) immediately (inside the setAccessoryView:
method), but the new accessory view won't be added to the cell until the cell's layoutSubviews
runs.
Upvotes: 2