2016-04-28 9 views
0

iOSで3d touch peek pop機能を実装しています。3D 1つのクラスの複数のボタンに触れる

これは、私は、これはちょうど私が同じクラスに3Dタッチを適用する4つの他のボタンを持って、同じビュー内の1つのボタンにあるボタン一つ

- (UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location 
{ 

    UIViewController *detailVC = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"]; 


    detailVC.preferredContentSize = CGSizeMake(0.0, 500.0); 

    previewingContext.sourceRect = self.btnDetail.frame; 

    return detailVC; 
} 

のために書かれているコードです。これどうやってするの??

答えて

1

場所を確認するだけで済みます。例:

- (UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location 
{ 
    if(CGRectContainsPoint(self.btnDetail.frame,location)){ 
     UIViewController *detailVC = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"]; 


     detailVC.preferredContentSize = CGSizeMake(0.0, 500.0); 

     previewingContext.sourceRect = self.btnDetail.frame; 

     return detailVC; 
    } 
    if(CGRectContainsPoint(self.otherBtn.frame,location)){ 
     UIViewController *otherVC = [self.storyboard instantiateViewControllerWithIdentifier:@"other"]; 


     otherVC.preferredContentSize = CGSizeMake(0.0, 500.0); 

     previewingContext.sourceRect = self.otherBtn.frame; 

     return otherVC; 
    } 
    … 
} 
関連する問題