背景图像设置问题(github上的GHWalkThrough库)

nic*_*ick 5 objective-c ios

这是我想在我的应用程序中使用的github上的一个演练开放库.

https://github.com/GnosisHub/GHWalkThrough

有一种设置bg视图的方法:

- (UIImage*) bgImageforPage:(NSInteger)index
{
    UIImage* image = [UIImage imageNamed:@"bgimage"];
    return image;
}
Run Code Online (Sandbox Code Playgroud)

我想为每个索引添加设置不同的图像,所以我这样做:

- (UIImage*) bgImageforPage:(NSInteger)index {

    UIImage* image;

    if (index == 0) {
        image = [UIImage imageNamed:@"screen 1"];
    } else if (index == 1) {
        image = [UIImage imageNamed:@"screen 2"];
    } else if (index == 2) {
        image = [UIImage imageNamed:@"screen 3"];
    } else if (index == 3) {
        image = [UIImage imageNamed:@"screen 4"];
    }

    return image;
}
Run Code Online (Sandbox Code Playgroud)

结果:

无论何时加载视图都有一个清晰的bg,如果我向左滑动到索引1,我得到屏幕1>如果我向左滑动索引2,3和4,bg保持屏幕1 ...

有人能看到这里有什么问题吗?

Von*_*onC 1

你似乎没有更新index,这意味着它保持在0。

如果它保持为 0,则图像将始终为"screen 1"