Reputation: 1375
I have this code:
Updated
-(IBAction)editDrivers:(id)sender
{
selDriverBrand = driverBrand;
selDriverModel = driverModel;
selDriverSize = driverSize;
driverParams *IView = [[driverParams alloc] initWithNibName:nil bundle:nil];
CGRect onScreenFrame = IView.view.frame;
//CGRect offScreenFrame = self.view.frame;
CGRect offScreenFrame = CGRectMake(self.view.frame.origin.x, self.view.bounds.size.height, self.view.bounds.size.width, self.view.bounds.size.height);
// ^Fails on this line.
}
and I'm getting an expected identifier before numeric constant error on the indicated line, but I can't figure out for the life of me why, I am doing the same thing in other functions without any problems.
Upvotes: 1
Views: 469
Reputation: 1375
I never did get it to work dynamically, instead I ended up checking for the iPad and then setting the origin accordingly:
-(IBAction)editDrivers:(id)sender
{
selDriverBrand = driverBrand;
selDriverModel = driverModel;
selDriverSize = driverSize;
driverParams *IView = [[driverParams alloc] initWithNibName:nil bundle:nil];
CGRect onScreenFrame = IView.view.frame;
CGRect offScreenFrame = self.view.frame;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{ offScreenFrame.origin.y = 1024; }
else
{ offScreenFrame.origin.y = 480; }
IView.view.frame = offScreenFrame;
[UIView beginAnimations:@"FakeModalTransition" context:nil];
[UIView setAnimationDuration:.5f];
[self.view addSubview:IView.view];
IView.view.frame = onScreenFrame;
[UIView commitAnimations];
}
Upvotes: 0
Reputation: 112857
If this line fails:
CGRect offScreenFrame = CGRectMake(self.view.frame.origin.x, self.view.bounds.size.height, self.view.bounds.size.width, self.view.bounds.size.height);
Then self
is not a UIViewController
.
Additionally:
ivars and vars should begin with a lowercase letter by convention--which ARC requires. So IView
would be better as: iView
(and syntax highligting would also be correct).
Class names should begin with a uppercase letter in order to follow conventions. driverParams
would be better as DriverParams
.
All this makes the code more readable to others.
Upvotes: 0
Reputation: 18157
Try to use:
offScreenFrame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.bounds.size.height);
Upvotes: 0
Reputation: 9453
You can't change the value of y
as it is a constant. To do what you want you need to create a new frame with the value of y
that you desire and then assign it to offScreenFrame
CGRect onScreenFrame = IView.view.frame;
CGRect offScreenFrame = CGRectMake(self.view.frame.origin.x, self.view.bounds.size.height, self.view.bounds.size.width, self.view.bounds.size.height);
Upvotes: 1