I am using this code:
CGRect myRect = CGRectMake(self.frame.size.width, self.frame.size.height);
But it gives this error:
- Property "frame" not found on object of type [myViewController]
Anyone have any ideas on how I should modify my code?
First of all, you have too few arguments for the CGRectMake
function. You need to define your origin. Also, you need to have self.view
instead of just self
. Looks something like this:
CGRect myRect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
the view frame of the view from within the code is being executed
CGRect myViewFrame = self.view.frame;
or the frame of the screen if that's what you want (says device in the title of the question)
CGRect screenFrame = [[UIScreen mainScreen] bounds];
or this which will return the same minus status bar if visible
CGRect actualyScreenFrame = [[UIScreen mainScreen] applicationFrame];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With