ios - How does sizeToFit determine appropriate size? -


i have app user can add call palettes @ will. items (uiviews) can dragged 1 palette another. thought use sizetofit method automatically resize palettes when items added ore removed, no resizing seems happening.

the documentation states method resizes appropriate size fit subviews. not include uiviews add programmatically?

i'd not have write own sizetofit method if can built-in 1 work me. seems doing nothing. here's code i've tried:

        cgpoint oldcenter = self.piecebeingmoved.center;         cgpoint newcenter = [self.piecebeingmoved.superview convertpoint:oldcenter toview:destinationview];         [destinationview addsubview:self.piecebeingmoved];         self.piecebeingmoved.center = newcenter;         if (destinationview.tag == 20000) {            nslog(@"destinationview palette, resize %@",nsstringfromcgrect(destinationview.frame));            [destinationview sizetofit];            nslog(@"destinationview resized %@",nsstringfromcgrect(destinationview.frame));         } 

the size identical before , after subview added. subview being added subview @ time ran test, , size of subview 5% size of palette being moved to. why isn't view being resized? need myself?

the sizetofit method calls sizethatfits: , resizes view accordingly. default implementation of uiview class returns current size don’t see effect. have write own sizethatfits: method calculation.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -