cocosStudio的使用-04-PageView无法垂直滑动解决办法

来源:互联网 发布:迷恋网络的危害 编辑:程序博客网 时间:2024/05/19 01:13

PageView相当凑合的一个控件,功能也凑合。

今天才发现,这东西居然连Vertical,horizontal都没得啊。

但是今天的任务需要竖直方向的滑动,我机智的把PageView旋转90度,里面的内容也旋转90度。

结果却让我浑身难受啊,控件整个垂直了,但是竖直的滑动不起作用,我们的手指横向滑动,PageView竖向移动。

这得有多蛋疼!!!


找了一圈也没发现解决办法,自己动手吧


1.首先找到这两个文件在我们引用的GUI中


2.打开头文件,添加一个bool Vertical;

构造函数中将其设为false。(bool默认为ture)



3.找到cpp中的void PageView::handleMoveLogic(Touch *touch)方法

判断Vertical是否为true,修改如下

void PageView::handleMoveLogic(Touch *touch)
{
    Vec2 touchPoint = touch->getLocation();
if (isVertical)
{
float offset = 0.0;
offset = touch->getPreviousLocation().y - touchPoint.y;


if (offset < 0)
{
_touchMoveDirection = TouchDirection::LEFT;
}
else if (offset > 0)
{
_touchMoveDirection = TouchDirection::RIGHT;
}
scrollPages(offset);
}
else
{
float offset = 0.0;
offset = touchPoint.x - touch->getPreviousLocation().x;


if (offset < 0)
{
_touchMoveDirection = TouchDirection::LEFT;
}
else if (offset > 0)
{
_touchMoveDirection = TouchDirection::RIGHT;
}
scrollPages(offset);
}
}

如果我们已经提前新建好了工程此路径下的头文件还需要修改一次(cpp不用改,编译通过,会自动连接引用的obj)


好了,这个方法比较简陋,还需要将pageView手动旋转90度。

希望有更好的方法,大家交流。

0 0
原创粉丝点击