2014-01-10 45 views
0

後,我把UITextField,一個UITextView與其它元素的UIView並設置自己的位置在實用面積的Xcode。我想要做的是將它們分組爲subView並將一些動畫應用於subView。 但將它們添加到新創建的subView改變自己的立場,看看這個圖片(前,將它們添加後):
以前
Before

After
綠色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]; 

回答

0

禁用自動佈局,在工具欄中。 可以通過取消選中使用Autolayout選項來完成。

下面是截圖:

enter image description here

相關問題