【问题标题】:Elements position get changed after adding them as subView将元素添加为子视图后,元素位置发生变化
【发布时间】:2014-01-10 07:08:18
【问题描述】:

我将UITextFieldUITextView 和另一个元素放在UIView 中,并在XcodeUtility Area 中设置它们的位置。我想要做的是将它们分组为subView 并将一些动画应用于subView。 但是在将它们添加到新创建的subView 之后改变它们的位置,看看这张图片(添加它们之前和之后):
之前

之后

绿色的UITextField 居中对齐,UITextView 消失了! (我现在不在乎UILabel 和那条水平线)。
这是我的代码:

    CGRect oldPosition = taskTitle.frame;

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
    [view setBackgroundColor:[UIColor redColor]];

    [view addSubview:taskTitle];
    [view addSubview:taskNote];
    [view addSubview:datePickerButton];

    taskTitle.frame=oldPosition;
    [self.view addSubview:view];

【问题讨论】:

    标签: objective-c xcode uiview xcode5


    【解决方案1】:

    在实用工具栏中禁用文件检查器的自动布局。 可以通过取消选中 Use Autolayout 选项来完成。

    这是截图:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-13
      • 1970-01-01
      • 2019-08-19
      • 1970-01-01
      • 2022-12-13
      • 2014-08-12
      • 1970-01-01
      • 2013-07-02
      相关资源
      最近更新 更多