【问题标题】:Shinobi chart not accessible when inside a scrollview在滚动视图中无法访问 Shinobi 图表
【发布时间】:2013-06-10 17:28:07
【问题描述】:

我的应用程序显示了一个水平滚动区域,其中应该包含两个使用 Shinobi 库实现的不同图表。由于我的分页滚动视图是使用 ATPagingView 制作的,因此我使用以下代码包含了图表:

- (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;
    }

图表可以正确显示,但是当我尝试滚动它时,可滚动容器不会移动以显示第二个图表。奇怪的是,如果我调整图表的大小以便有一些空间与底层容器交互,或者如果我使用普通视图执行相同的操作,例如:

- (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;
    }

嗯..它工作得很好。 看起来 ShinobiChart 视图以某种方式拦截了触摸事件而不转发到滚动视图。如您所见,我尝试激活用户交互,但它不起作用。将图表装箱到另一个视图中也不起作用。

有什么想法吗?

【问题讨论】:

    标签: charts uiscrollview uiscrollviewdelegate shinobi


    【解决方案1】:

    在这里找到了可能的解决方案。显然是一个众所周知的问题,唯一的解决方法是禁用包含图表的视图的平移手势。

    chartView.gesturePanType = SChartGesturePanTypeNone;
    

    这是来源:

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

    【讨论】:

      猜你喜欢
      • 2013-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多