2016-05-28 116 views
0

我試圖寫我自己的自定義UIStoryboardSegue其中UIViewsourceViewController「滑」到destinationViewController。目前,我的代碼如下:自定義UIStoryboardSegue不工作

- (void)perform { 
    UIViewController *sourceViewController = self.sourceViewController; 
    UINavigationController *navigationController = [[self sourceViewController] navigationController]; 
    RestaurantViewController *destinationViewController = self.destinationViewController; 

    destinationViewController.colors.frame = CGRectMake(0, 0, 10, 10); 

    [sourceViewController.view addSubview:destinationViewController.tables]; 

    [UIView animateWithDuration:10.0 
          delay:0.0 
         options:UIViewAnimationOptionCurveEaseInOut 
        animations:^{ 
         destinationViewController.tables.frame = CGRectMake(100, 100, 100, 100); 
        } 
        completion:^(BOOL finished){ 
         [destinationViewController.tables removeFromSuperview]; // remove from temp super view 
         [navigationController pushViewController:destinationViewController animated:NO]; // present VC 
        }]; 
} 

作爲一個測試,我只是玩弄表視圖的框架。我還將持續時間設置爲10秒鐘,以便我能看到所有內容。但是,destinationViewController只是完成了,完全忽略了我寫的所有代碼。我在這裏做錯了什麼?

回答

0

您好,我正在嘗試使用您的代碼來完成這項工作,但我發現您的主要問題是您的destinationViewController.tables是零,這就是爲什麼沒有任何工作。

你需要確保你的destinationViewController.tables不是零,你可以在你RestaurantViewController類像這樣

- (instancetype)initWithCoder:(NSCoder *)coder 
     { 
     self = [super initWithCoder:coder]; 
     if (self) { 
      self.tables = [[UIView alloc]initWithCoder:coder]; 
     } 
     return self; 
     } 

希望這有助於你做到這一點。對不起,我的英語