CGRectMake不与UIView合作 [英] CGRectMake is not working with UIView

查看:94
本文介绍了CGRectMake不与UIView合作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天花了几天时间只是为了在我的应用程序加载时隐藏PickerView,但问题不在于PickerView。它与CGRectMake一起。

I spent hours of my day today just to hide PickerView when my app is loaded, but the problem is not with the PickerView. it's with CGRectMake.

我在Xcode上尝试了一个简单的项目,只是为了向您展示CGRectMake对我不起作用......

I tried a simple project on Xcode just to show you that CGRectMake doesn't work for me...

这是我的故事板(灰色区域是UIView组件):

here's my storyboard (grey area is UIView component) :

这是我的界面:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *container;

@end

这是我的实施文件:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _container.frame = CGRectMake(0, 0, 320, 204);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

这是非常基本的代码,不是被其他代码污染......但是,给予CGRectMake的任何数字都不会使灰色区域移动。我已经改变了X,Y值,但是灰色的UIView仍然像你在故事板上看到的那样。

it's very basic code, not contaminated with other codes... but still, any numbers given to that CGRectMake doesn't make that grey area move. I've changed X, Y value, but the grey UIView stand still just like what you see on storyboard.

为什么CGRectMake不能处理我的情况?问题在哪里?

why CGRectMake is not working on my case? where's the problem?

更新:我在检查员框中看到了autolayout

UPDATE : I see autolayout is checked on my inspector box

更新:这是我的连接检查器

UPDATE : here's my Connection inspector

推荐答案

如果您为故事板启用 AutoLayout 然后更改视图的框架将无效。

If you have AutoLayout enabled for the Storyboard then changing the frame of a view won't work.

您无法使用<$直接更改框架C $ C>自动版式。您必须更改它们周围的约束。

You can't change frames directly using AutoLayout. You have to change the constraints around them.

如果您为故事板禁用 AutoLayout 它会起作用。

If you disable AutoLayout for the Storyboard it will work.

这篇关于CGRectMake不与UIView合作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆