我的ViewController在最初加载时是这样的:

当点击显示按钮时,它必须像这样改变:

我的代码是:
- (IBAction)show:(id)sender {
[self change];
[tableView reloadData];
}
- (IBAction)close:(id)sender {
[self change];
[tableView reloadData];
}
-(void)change{
//assigning initial bounds to frame-1
CGRect frame1=CGRectMake(0, _pastProcessTV.frame.origin.y, self.view.bounds.size.width, self.pastProcessTV.bounds.size.height);
//assigning new bounds to frame-2
CGRect frame2=CGRectMake(0, **CGFloat y**,self.view.bounds.size.width,***CGFloat height***);
if (_showFullButton.isTouchInside) {
tableView.frame = frame2;
}
else{
tableview.frame = frame1;
}
}我试过不同的方法。这不是working.can,谁能帮我给出Y坐标和宽度
发布于 2016-03-02 19:41:19
当你使用autolayout时,你必须从表视图的topconstraint中取出,当你想要展开它时,将它的值设置为0
因此,它将按预期工作
如果使用的是iOS 7
[self.view layoutIfNeeded]是不可抗拒的
发布于 2016-04-11 16:09:01
如果你必须使用自动排版,请尝试这样的图片
Make Layout Constraint Property
并尝试以下代码
#import "ViewController.h"
@interface ViewController ()
{
CGFloat oldtableViewTopValue;
}
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableViewTopLC;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
oldtableViewTopValue = _tableViewTopLC.constant;
}
- (IBAction)showBtnAction:(id)sender
{
[UIView animateWithDuration:0.5f animations:^{
_tableViewTopLC.constant = (_tableViewTopLC.constant==oldtableViewTopValue ? 0 : oldtableViewTopValue);
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
}];
}
@end发布于 2016-03-02 20:11:22
请关闭情节提要中的自动布局

https://stackoverflow.com/questions/35746142
复制相似问题