2016-12-05 1 views
0

cwRichardKim/TinderSimpleSwipeCards을 사용합니다. 내 First view controller에서 제대로 작동합니다. 이제 다른 JSON 어레이가있는 다른 View Controller에서이 기능을 사용하고 싶습니다. 이것을 어떻게 할 수 있습니까?두 개의 서로 다른 뷰 컨트롤러와 배열을위한 프레임 워크를 사용하여

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에 : 다른 JSON 배열에 대한

-(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]; 
     } 
    } 

내가 같은 클래스를 사용하거나 내가 다른 클래스를 확인해야 이것은 내가 내 first ViewController에 어떻게 무엇입니까?

+0

질문을 제대로받지 못했습니다! – Lion

+0

예,이 클래스를 다른 JSON 배열과 함께 사용할 수 있습니다. –

+0

어떻게 그때 사용할 수 있습니다 ... @ SaurabhJain –

답변

0

여러 개의 뷰 컨트롤러에 동일한 DraggableViewBackground 클래스를 사용할 수 있습니다. 당신이 디자인을 카드 & 데이터를 변경하려는 경우 당신은 당신이 다른 DraggableViewBackground 클래스를 사용할 수 있습니다,이 라인에서

[draggableBackground loadCards: yourArray]; 

을 배열을 변경해야합니다. 모든 메소드를 DraggableViewBackground에서 새 DraggableViewBackground 클래스로 복사하십시오.

디자인에 따라 새로운 DraggableViewBackground.m 변경 -(void)setupView 메서드에서. 데이터에 따라 -(DraggableView *)createDraggableViewWithDataAtIndex:(NSInteger)index 방법을 변경하십시오.

그리고 새로운 DraggableViewBackground 클래스를 두 번째ViewController에 사용하십시오.

+0

카드에 데이터가 나타나지만 모델에 따라 변경해야합니다 .... 우리가 할 수있는 일 MGInvitationModel * model = [self.exampleCardLabels objectAtIndex : index] ; namelabel.text = model.senderName; –

+0

질문을 올바르게받지 못했습니다. 카드의 디자인을 변경 하시겠습니까? –

+0

예 및 그 이상의 데이터 –

관련 문제