2013-08-03 45 views
3

我使用UIStoryboard中的segue在我的代碼中加載視圖控制器。基於少數用戶選擇的選項,我然後使用動畫隱藏或顯示UI控件。它一切正常。Modal View正在重置我的現有視圖控制器

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil]; 

    SigningViewController *signingVC = (SigningViewController *)[storyboard instantiateViewControllerWithIdentifier:@"SigningViewController"]; 
    signingVC.object = self; 
    signingVC.signatureProperty = @"employeeSignature"; 
    signingVC.startDate = self.startDate; 
    signingVC.endDate = self.endDate; 

    [self presentViewController:signingVC animated:YES completion:nil]; 

此代碼時觸發如預期,除了一兩件事都發生了:所有的自定義

- (void)showComments { 
    NSLog(@"Show Comments"); 
    _commentsTextView.hidden = NO; 
    _commentsTextView.frame = CGRectMake(435, 266, 475, 134); 

    [UIView animateWithDuration:1 animations:^{ 
     _commentsTextView.alpha = 1; 
     _signatureButton.frame = CGRectMake(435, 420, 475, 134); 
     _cancelButton.frame = CGRectMake(568, 581, 100, 44); 
     _finishedButton.frame = CGRectMake(676, 581, 100, 44); 
    }]; 

}

然後我用下面的代碼呈現在UIStoryboard創建一個視圖控制器隱藏或顯示UI控件的動畫恢復。就好像通過調用presentViewController方法,它正在從UIStoryboard重繪我現有的視圖。

有沒有辦法讓它在模態顯示新視圖之前重新繪製/重新加載我的現有視圖?

回答

0

我也有同樣的問題。無論我試圖讓動畫在模式關閉時發生變化,它似乎都會重置回原始故事板。

我必須去的解決方案是添加任何動畫視圖作爲頭文件的出口。從視圖控制器的self.view或主視圖中取出視圖並以編程方式將其添加爲子視圖。將框架設置到你想要的位置,並且在結束模態之後所有的動畫位置都應該是相同的。如果你需要更多的解釋並讓我知道,它對我很有用。

0

我只是遇到了同樣的問題,並以更詳細的形式發佈在此處,名爲kokx的用戶幫了我很多,其答案在my question page中有記錄。

相關問題