iPhone – 无法更改UIView帧大小

前端之家收集整理的这篇文章主要介绍了iPhone – 无法更改UIView帧大小前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个自定义uiview,我正在尝试更新帧大小.点击后,我会在方法中这样做.调用方法,帧值发生变化,但屏幕上没有任何反应!

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");
    }

解决方法

我猜你已经在Interface Builder中将self.view挂钩到了UIView.

为了更改UIView框架,在Interface Builder中转到File Inspector,取消选中Use Autolayout,然后在代码中更改框架.

希望这可以帮助.

猜你在找的Xcode相关文章