3

The following code works perfectly on iOS 7.1

UIView *superView = self.superview;
[self removeFromSuperview];
CGFloat rightMarginWidth = self.rightMarginWidth ? self.rightMarginWidth : defaultRightMarginWidth;
CGRect newFrame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width + rightMarginWidth, self.frame.size.height);
//assign a new frame
self.frame = newFrame;
[superView addSubview:self];

However, on iOS 8.0, suppose newFrame is origin=(x=30, y=29) size=(width=127, height=34). After the assignment, self.frame became origin=(x=0, y=0) size=(width=127, height=34).

Why the "origin" value is lost here?

David Liu
  • 16,374
  • 12
  • 37
  • 38

1 Answers1

-1

If the view controller has autolayout constraints, you should add self.translatesAutoresizingMaskIntoConstraints = YES;

xgord
  • 4,606
  • 6
  • 30
  • 51
Khaled Zayed
  • 306
  • 2
  • 6