2016-12-05 9 views
0

を使用しています。cwRichardKim/TinderSimpleSwipeCardsを使用しています。私のFirst view controllerで正常に動作しています。今私は別のJSONアレイと異なるViewコントローラでこれを使用したいと思います。どうすればこれを達成できますか?これは私が私のfirst ViewControllerで行う方法です。2つの異なるビューコントローラと配列のフレームワークを使用して

CGRect frame = self.invitationViewContainer.frame; 
    //frame.origin.y = -self.view.frame.size.height; //optional: if you want the view to drop down 
     DraggableViewBackground *draggableBackground =  [[DraggableViewBackground alloc]initWithFrame:frame]; 
    draggableBackground.alpha = 0; //optional: if you want the view to fade in 

    [draggableBackground loadCards:_arrAllCards]; 

    [self.invitationViewContainer addSubview:draggableBackground]; 

DraggableViewBackground ViewClassで:

-(void)loadCards:(NSArray*)array 
    { 

    exampleCardLabels = array; 


    if([exampleCardLabels count] > 0) { 
    NSInteger numLoadedCardsCap =(([exampleCardLabels count] > MAX_BUFFER_SIZE)?MAX_BUFFER_SIZE:[exampleCardLabels count]); 
    //%%% if the buffer size is greater than the data size, there will be an array error, so this makes sure that doesn't happen 



     //%%% loops through the exampleCardsLabels array to create a card for each label. This should be customized by removing "exampleCardLabels" with your own array of data 
     for (int i = 0; i<[exampleCardLabels count]; i++) { 
     DraggableView* newCard = [self createDraggableViewWithDataAtIndex:i]; 
     [allCards addObject:newCard]; 

     if (i<numLoadedCardsCap) { 
      //%%% adds a small number of cards to be loaded 
      [loadedCards addObject:newCard]; 
     } 
    } 

異なるJSON配列のために、私は同じクラスを使用するか、私は別のクラスを作成することができますか?

+0

質問が正しく表示されません。 – Lion

+0

はい、このクラスを別のJSON配列で使用できます。 –

+0

どうすればそれを使うことができますか... @ SaurabhJain –

答えて

0

複数のViewControllerに同じDraggableViewBackgroundクラスを使用できます。あなたはちょうどあなたがデザインにカードの&データを変更したい場合は、別のDraggableViewBackgroundクラスを使用することができ

[draggableBackground loadCards: yourArray]; 

、このラインからの配列を変更する必要があります。すべてのメソッドをDraggableViewBackgroundから新しいDraggableViewBackgroundクラスにコピーします。

デザインでは、新しいDraggableViewBackground.mの変更-(void)setupViewメソッドにあります。 データに応じて-(DraggableView *)createDraggableViewWithDataAtIndex:(NSInteger)indexメソッドを変更してください。

そして、新しいDraggableViewBackgroundクラスを2番目のViewControllerに使用します。

+0

カードにもデータが表示されますが、モデルによっても変更する必要があります....それではどうすればいいですか MGInvitationModel * model = [self.exampleCardLabels objectAtIndex:index] ; namelabel.text = model.senderName; –

+0

ご質問が適切に行われません。あなたはカードのデザインを変更しますか? –

+0

はいまたそれ以上のデータ –

関連する問題