UIViewController 的frame 无法修改

rollrock1987 2013-04-11 12:05:20
我想修改下 UIViewController 的view的frame,在viewDidLoad的时候修改了是对的

但是为什么在ddd函数里面打印出来的跟没修改之前是一样的呢?(没有其他任何代码)

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.

CGRect frame = self.view.frame;

frame.size.height -= 100;
self.view.frame = frame;

NSLog(@"Rollrock-%f-%f",self.view.frame.origin.y,self.view.frame.size.height);

NSLog(@"Rollrock~%f-%f",self.view.bounds.origin.y,self.view.bounds.size.height);

UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
[btn addTarget:self action:@selector(ddd) forControlEvents:UIControlEventTouchDown];

[self.view addSubview:btn];


self.view.backgroundColor = [UIColor redColor];
}

-(void)ddd
{
NSLog(@"Rollrock-%f-%f",self.view.frame.origin.y,self.view.frame.size.height);

NSLog(@"Rollrock~%f-%f",self.view.bounds.origin.y,self.view.bounds.size.height);
}
...全文
409 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouming0100 2014-04-20
  • 打赏
  • 举报
回复
viewDidLoad,函数,将整个view已经加载到内存中,你修改时无效的。
不担心 2013-04-12
  • 打赏
  • 举报
回复
都没看到你调用ddd方法
rollrock1987 2013-04-11
  • 打赏
  • 举报
回复
楼上的 跟我的 有什么不一样么?
Evan_Lei 2013-04-11
  • 打赏
  • 举报
回复
self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 100);

29,049

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧