how to pass cgrect as parameter and how to get cgrect as a return type in ipad
hi all i am going to ask basic question i searched many links for my question but none of the things not given exact result.here is my question:
I want to pass rect value and returning the same type using some transformation for that i wrote one method but it is giving me the errors i know it may be syntactically wrong please correct the below code
-(void)viewDidLoad{
CGRect testRect=getNewRect(self.view.frame);
}
m开发者_C百科y own method is here
CGRect getNewRect(CGRect normalRect){
//some transformation
return tranfermedrect;
}
give me your suggestion thanks in advance..
Used following line you will solve your problem.
[self yourFunction:[NSValue valueWithCGRect:rectFrame]];
Above line is the simple method call and in objective-C you can not send CGRect as a parameter. so you have to CGRect convert into NSValue.
At called function you have get GGRect from NSValue
yourView.frame = [rect CGRectValue];
I hope it will help you.
Try with below
-(void)viewDidLoad{
CGRect testRect= [self getNewRect:self.view.frame];
}
-(CGRect) getNewRect:(CGRect) normalRect{
//some transformation
return tranfermedrect;
}
Add below in .h file
-(CGRect) getNewRect:(CGRect) normalRect ;
-(void)viewDidLoad{
CGRect testRect= [self getNewRect:self.view.frame];
NSLog(@"New rect %@",NSStringFromCGRect(testRect));
}
-(CGRect) getNewRect:(CGRect) normalRect{
//some transformation
return tranformedRect;
}
see if this works
精彩评论