ios - iCarousel multiple nibs -
i've been messing around icarousel (linky: https://github.com/nicklockwood/icarousel) while , there's 1 thing can't head around.
it's loading 2 or more nibs 1 carousel. current code load same nib items in carousel:
- (uiview *)carousel:(icarousel *)carousel viewforitematindex:(nsuinteger)index reusingview:(uiview *)view { if (!view) { //load new item view instance nib //control events bound view controller in nib file view = [[[nsbundle mainbundle] loadnibnamed:@"itemview" owner:self options:nil] lastobject]; } return view; }
it's standard code controlsdemo in icarousel.
am right in saying simple if statement can applied code above populate carousel different nib each item?
or have go down route of loading array of nib files @ start , reference them in method above?
or there different way this?
the issue incredibly simple, on complicating big time.
here's code added above sample fix it:
- (uiview *)carousel:(icarousel *)carousel viewforitematindex:(nsuinteger)index reusingview:(uiview *)view { if (index == 0) { view = [[[nsbundle mainbundle] loadnibnamed:@"nib1" owner:self options:nil] lastobject]; } else { view = [[[nsbundle mainbundle] loadnibnamed:@"nib2" owner:self options:nil] lastobject]; } return view; }
Comments
Post a Comment