i am trying to get x,y coordinates and height,width of an imageview of the view controller in another class..but i failed ...please tell me where did i made mistake..?
this is my code of view controller and class that i given to the view controller
view controller.m
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. dot1=[[UIImageView alloc]initWithFrame:CGRectMake(145, 30, 20, 20)]; dot1.backgroundColor=[UIColor blackColor]; dot1.layer.cornerRadius=11.0; dot2=[[UIImageView alloc]initWithFrame:CGRectMake(80, 130, 20, 20)]; dot2.backgroundColor=[UIColor blackColor]; dot2.layer.cornerRadius=11.0; NSLog(@" (x==%f,y==%f,w==%f,h==%f)",dot1.frame.origin.x,dot1.frame.origin.y,dot1.frame.size.width,dot1.frame.size.height);//here i got the correct output.. } and this code belongs to the class view.m....
- (void)drawRect:(CGRect)rect { ViewController*vc=[[ViewController alloc]init]; NSLog(@"(x==%f,y==%f,w==%f,h==%f)",vc.dot1.frame.origin.x,vc.dot1.frame.origin.y,vc.dot1.frame.size.width,vc.dot1.frame.size.height);//but here i got all points 0. } note: i gives class to the view controller is view.