thefaj / OpenFlow

CoverFlow API replacement for the iPhone
http://apparentlogic.com/openflow
818 stars 158 forks source link

Can't use properly when integrating OpenFlow strictly with code (no IB) #2

Open dejo opened 15 years ago

dejo commented 15 years ago

I am trying to add an OpenFlow view in code rather than through IB. But setUpInitialState expects self.datasource to already be set which is impossible when using the standard: AFOpenFlowView *openFlowView = [[AFOpenFlowView alloc] initWithFrame:CGRectMake(...)];

I can't set openFlowView.datasource = self; until after this line.

JaredCrawford commented 14 years ago

I think you're doing something wrong. I have this code working just fine. There may be some other issue.

flowView = [[AFOpenFlowView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; flowView.dataSource = self; flowView.viewDelegate = self; [flowView setNumberOfImages:12]; [self.view addSubview:flowView];

dejo commented 14 years ago

initWithFrame:, after taking care of its super class duties, calls [self setUpInitialState];, right? And the first thing setUpInitialState does is set up the default image via self.defaultImage = [self.dataSource defaultImage]. But, at this point, self.dataSource has not yet been set and is nil.

jamis commented 14 years ago

I worked around this by adding the following to AFOpenFlowView:

- (void)setDataSource:(id<AFOpenFlowViewDataSource>)theDataSource {
  dataSource = theDataSource;
  self.defaultImage = [self.dataSource defaultImage];
}