Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot change UIView frame size

I have a custom uiview that i am trying to update the frame size. I do it like this in a method once it is clicked. The method is called, and the frame value changes, however on the screen nothing happens!

if (!touched) {

        GameBox *box = (GameBox *)[self.view viewWithTag:40];

        [box setFrame:CGRectMake(20, 20, 100, 73)];
        NSLog(@"%f", box.frame.origin.x);
        markButton.enabled = NO;
        guessButton.enabled = NO;
        [self.view reloadInputViews];

        NSLog(@"The action bar should now be hidden");
    }
    else if (touched) {
        guessButton.enabled = YES;
        markButton.enabled = YES;
        [self.view reloadInputViews];
        NSLog(@"The action bar should now be visible");
    }
like image 740
michaela Avatar asked Nov 27 '22 14:11

michaela


1 Answers

I guess you have hooked self.view to UIView in Interface Builder.

In order to change UIView frame, in Interface Builder go to File Inspector, and uncheck Use Autolayout, then in the code change the frame.

Hope this helps.

like image 184
Anh Nguyen Avatar answered Nov 30 '22 03:11

Anh Nguyen