gpt4 book ai didi

objective-c - 更改 self.view 框架不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:06:14 24 4
gpt4 key购买 nike

我有以下结构:

UIViewController > UIView (self.view) > UITableView (self.tableView - IBOutlet)

我尝试将整个内容向上移动 59 像素,我尝试过:

- (void)viewWillAppear:(BOOL)animated {

self.view.frame = CGRectMake(0, -59, 320, 367 + 59);
// or
self.tableViewMe.frame = CGRectMake(0, -59, 320, 367 + 59);;

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

NSLog(@"%f", self.tableView.frame.origin.x);
NSLog(@"%f", self.tableView.frame.origin.y);
NSLog(@"%f", self.tableView.frame.size.width);
NSLog(@"%f", self.tableView.frame.size.height);

[super viewWillAppear:animated];

}

坐标是对的,但是view和table是一样的,根本不动。此外,如果我将以下代码添加到 IBAction,例如点击按钮,那么它就可以工作了:

self.view.frame = CGRectMake(0, -59, 320, 367 + 59);

最佳答案

尝试将其粘贴在 viewDidAppear 而不是 viewWillAppear 中。

关于objective-c - 更改 self.view 框架不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13235022/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com