【发布时间】:2016-12-05 06:04:33
【问题描述】:
我正在使用cwRichardKim/TinderSimpleSwipeCards。它在我的First view controller 上运行良好。现在我想在具有不同JSON 数组的不同视图控制器中使用它。我怎样才能做到这一点?这就是我在first ViewController 中的做法:
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 数组,我可以使用相同的类还是必须创建不同的类?
【问题讨论】:
-
没有正确回答您的问题!
-
是的,您可以将此类与不同的 JSON 数组一起使用。
-
那怎么用...@SaurabhJain
标签: ios objective-c arrays json