Multiple CGRect

Discussion in 'iOS Programming' started by dragonpme, Jan 3, 2011.

  1. dragonpme, Jan 3, 2011
    Last edited: Jan 3, 2011

    dragonpme macrumors newbie

    Oct 14, 2010
    I am the producer of Face Factory.

    This is a link to the free version for ipad.

    In my app i have a fundamental flaw that i cannot seem to eradicate. When two items of the same are spawned, the first spawn becomes no longer active in my view.

    Each Facial feature has a button, of which spawns a CGRect. I think when the buttons is pressed for a second time, the second spawned CGRect has the same name, dimensions etc, and thus has totally overwritten any existence of the old. So movement and resizing of the old is no longer an option.

    Can anyone help me solve this dilemma, as i wish to be able to have more than one of the same item at the same time.

    Thank you.


    -(IBAction) zfridge{

    CGRect zfridgeRect = CGRectMake(50.0f, 250.0f, 100.0f, 100.0f);
    zfridge = [[UIImageView alloc] initWithFrame:zfridgeRect];
    [zfridge setImage:[UIImage imageNamed:mad:"Z.png"]];
    zfridge.opaque = NO;
    zfridge.userInteractionEnabled = YES;
    zfridge.multipleTouchEnabled = YES;

    [self.view addSubview:zfridge];
    [zfridge release];
  2. nickculbertson macrumors regular


    Nov 19, 2010
    Nashville, TN
    I don't know a short cut way to do what you need. my solution would be to copy three or so buttons for each face button. stack those buttons on top of one another and code if button1 is pressed it is hidden, revealing another button. have button two have this.
    -(IBAction) zfridge2{
    CGRect zfridge2Rect = CGRectMake(50.0f, 250.0f, 100.0f, 100.0f);
    zfridge2 = [[UIImageView alloc] initWithFrame:zfridge2Rect];
    [zfridge2 setImage:[UIImage imageNamed:@"Z.png"]];
    zfridge2.opaque = NO;
    zfridge2.userInteractionEnabled = YES;
    zfridge2.multipleTouchEnabled = YES;
    [self.view addSubview:zfridge2];
    [zfridge2 release];
    create a button and action for as many of each item you want.


Share This Page