I am presenting an instance of UINavigationController
modally with the modalPresentationStyle
set to UIModalPresentationFormSheet
. Inside the UINavigationController
is an UITableViewController
. For a delete button in the table view, I have to know the width of the sheet. Is there any way to access this?
I tried [self.view bounds]
, however this returns the with of the screen. I think that's because the view is not visible at the time a call this, however I don't know where else I should call it.
You can directly measure and store a magic value for the form sheet width (not pretty, I know, but it works) the value that I have been using is 540.
If you really want to get it programatically. You'll have to make sure that the view has been resized and prepped for presentation before taking the bounds value from the view. I believe this happens somewhere between viewWillAppear and viewDidAppear, although I can't remember exactly.
If all you want to do is ensure a button is aligned to the right, try using the autoresizingMask property of the button. I believe you'll only need to use UIViewAutoresizingFlexibleLeftMargin.