首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从忽略约束的代码加载故事板

从忽略约束的代码加载故事板
EN

Stack Overflow用户
提问于 2015-09-14 20:12:05
回答 1查看 67关注 0票数 0

我有一个故事板构建的视图与约束,看起来很好时,通过IB加载。当我试图从代码中加载相同的视图时,视图看起来被正确地放置在视图中,但是我的所有约束都关闭了,并且在编辑时看不到模拟器中的更改。

这是我用来加载视图的代码-

代码语言:javascript
复制
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Pop" bundle:nil];
    UIViewController *vc = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"FreshPopViewController"];

    firstPopView = vc.view;
    vc.view = nil;

    //firstPopView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    //[firstPopView setFrame:self.view.frame];
    [firstPopView setFrame:self.view.bounds];

    UIButton *requestButton = (UIButton*)[self.view viewWithTag:101];

    [requestButton addTarget:self action:@selector(newRequestButtonClicked) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:firstPopView];

正如您在代码中看到的,我尝试过不同的方法来设置框架,但这似乎没有什么区别。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-15 14:23:05

我能够通过在VC的视图和我的所有对象之间添加一个包含的视图来修复这个问题。我不需要在代码中编辑任何东西,只需在IB中重做对这个新视图的约束。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32573120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档