OpenFlow icon indicating copy to clipboard operation
OpenFlow copied to clipboard

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

Open dejo opened this issue 15 years ago • 3 comments

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.

dejo avatar Dec 03 '09 18:12 dejo

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

JaredCrawford avatar Dec 22 '09 03:12 JaredCrawford

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.

dejo avatar Dec 22 '09 15:12 dejo

I worked around this by adding the following to AFOpenFlowView:

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

jamis avatar Oct 08 '10 21:10 jamis