I am trying to use CGRectMake to assign a place and size to a uiimageview, here is the code;
-(IBAction)done11 {
[self performSelector:@selector(multibuttonvoid) withObject:nil afterDelay:2.0];
}
-(void)multibuttonvoid {
UIImageView *multibtn = [UIImageView alloc];
multibtn.image = [UIImage imageNamed:@"multibuttonpic"];
multibtn = CGRectMake(159, 325, 438, 318);
[self.view addSubview:multibtn];
}
So, as you can see if i press a button it should add a uiimageview with a picture. But for some reason, i get this error on the CGRectMake line: Assigning uiimageview to incompatible type CGRect, I thought a CGRect was a uiimage
A CGRect, a UIImage, and a UIImageView are completely different things.
CGRect is a simple stucture defining a rectangle in some arbitrary coordinate space, using a point (origin) and size (size).
A UIImage is an image and associated metadata.
A UIImageView is a UIView that is intended for displaying a UIImage.
It looks like what you really want is to set the frame
property of your UIImageView, to instruct it as to where on the screen it should display:
multibtn.frame = CGRectMake(159, 325, 438, 318);
Also, BTW, don't forget to initialize your UIImageView, by calling either initWithImage:
, initWithFrame:
, or the like on it. This is usually done at the same time as the allocation:
UIImageView *multibtn = [[UIImageView alloc] initWithImage:...];