Question

My application shows an horizontally scrollable area which should contain two different chart implemented using the Shinobi libraries. As my paged Scrollview is made using ATPagingView, I included the chart using the following code:

- (NSInteger)numberOfPagesInPagingView:(ATPagingView *)pagingView {
    return 2;
}
    - (UIView *)viewForPageInPagingView:(ATPagingView *)pagingView atIndex:(NSInteger)index {

        // Instantiate a tutorial item controller and initialise with the proper content
        self.chartView = [[ShinobiChart alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
        chartView.title = @"example charts";
        chartView.autoresizingMask = ~UIViewAutoresizingNone;
        // Use a number axis for the x axis.
        SChartNumberAxis *xAxis = [[SChartNumberAxis alloc] init];
        chartView.xAxis = xAxis;
        // Use a number axis for the y axis.
        SChartNumberAxis *yAxis = [[SChartNumberAxis alloc] init];
        chartView.yAxis = yAxis;
        chartView.datasource = self;
        chartView.userInteractionEnabled = YES;
        return chartView;
    }

The chart gets displayed correctly but, when I try to scroll it, the scrollable container doesn't move to show the second chart. The strange thing is that if I resize the chart in order to have some space to interact with the underlying container or if I do the same operation with a plain view like:

- (UIView *)viewForPageInPagingView:(ATPagingView *)pagingView atIndex:(NSInteger)index {

        // Instantiate a tutorial item controller and initialise with the proper content
        self.chartView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
        return chartView;
    }

well..it works perfectly. It looks like the ShinobiChart view is somehow intercepting the touch event and not forwarding to the scrollview. As you can notice I tried to activate the user interaction but it doesn't work. Boxing the chart inside another view doesn't work either.

Any idea?

Était-ce utile?

La solution

Found a possible solution here. Apparently is a well know issue and the only workaround is to disable pan gestures for the view containing the chart.

chartView.gesturePanType = SChartGesturePanTypeNone;

This is the source:

http://www.shinobicontrols.com/forum/shinobicontrols/2013/5/propagate-gesture-events-to-containing-controller-(shinobicharts)/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top