iOS 6 Autolayout工作不正常,在iOS 7中运行良好

时间:2014-04-21 13:29:33

标签: ios iphone objective-c ios6 autolayout

因为我不太了解汽车布局。所以这是我第一个使用自动布局的应用程序。这可能是重复的,但我需要你的帮助来解决它。

我的问题是我有一个视图,其中按钮点击事件我显示了一个下拉列表,其中包含2 UITextFields和1 UIButton,这在iOS 7中运行正常。但是当我尝试使用iOS 6,第一次下拉视图的子视图,如1个按钮和2 UITextFields位置,完全混乱,当我关闭下拉并尝试重新打开它显示正确的下拉视图与iOS 7相同。

This is the first time when I push the view showing blank

This is when I close the drop down view and reopen it

显示下拉视图的代码是

      - (IBAction)show:(id)sender 
        {
          self.dropDownContainerView.hidden=NO;
          addMemberPopup = [[DropDownPopup alloc] initWithContentView:self.dropDownContainerView];
          addMemberPopup.delegate = self;
          addMemberPopup.title = @"Add Member";
          [addMemberPopup showInView:self.view animated:YES];
        }

    - (BOOL) showInView:(UIView *)parentView animated:(BOOL)animated
     {
        self.frame = parentView.bounds;

       CGRect internalViewFrame = CGRectInset(self.contentView.bounds, -MARGIN, -(int)(MARGIN * 1 + HEADERHEIGHT / 2));
       internalViewFrame.size.height -= 2;
       internalViewFrame.origin = CGPointMake(0, -MARGIN);
       self.internalMainView.frame = internalViewFrame;

       CGRect internalMainViewFrame = CGRectOffset(internalViewFrame, (int)(self.frame.size.width - self.internalMainView.frame.size.width) / 2, 0);
       self.internalMainView.frame = internalMainViewFrame;

       [parentView addSubview:self];

      if (animated)
       {
           int actualHeight = self.internalMainView.frame.size.height;
           CGRect internalMainViewFrame = CGRectMake(self.internalMainView.frame.origin.x,                self.internalMainView.frame.origin.y, self.internalMainView.frame.size.width, 0);
           self.internalMainView.frame = internalMainViewFrame;

          CGFloat animationDuration = ANIMATIONDURATION;
          CGRect finalInternalMainViewFrame = CGRectMake(self.internalMainView.frame.origin.x, self.internalMainView.frame.origin.y, self.internalMainView.frame.size.width, actualHeight);

          [UIView animateWithDuration:animationDuration animations: ^(void) {
          self.internalMainView.frame = finalInternalMainViewFrame;
         }

        ];
       }    

return YES;

}

请帮我解决一下。感谢。

0 个答案:

没有答案