this is a walkthrough open library on github that I want to use in my app.
https://github.com/GnosisHub/GHWalkThrough
there is a method to set up bg view:
- (UIImage*) bgImageforPage:(NSInteger)index
{
UIImage* image = [UIImage imageNamed:@"bgimage"];
return image;
}
And I wanted to add set different image for each index, so i did this:
- (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;
}
Result:
whenever the view is loaded there is a clear bg, and if I swipe left to index 1 I get screen 1 > and if I swipe left for index 2, 3 & 4 the bg stays screen 1...
Can someone see what is wrong here?
i think you have minor mistak from code.
- (UIImage*) bgImageforPage:(NSInteger)index
{
NSString* imageName =[NSString stringWithFormat:@"bg_0%ld.jpg", index+1]; // you have manually add name but not increment index
UIImage* image = [UIImage imageNamed:imageName];
return image;
}
if you can't use bottom code & use upper code you got your result or same as use bottom code & use upper code then also you got same result.
- (UIImage*) bgImageforPage:(NSInteger)index
{
NSString* imageName =[NSString stringWithFormat:@"bg_0%ld.jpg", index+1];
UIImage* image;// = [UIImage imageNamed:imageName];
if (index == 0) {
image = [UIImage imageNamed:imageName];
} else if (index == 1) {
image = [UIImage imageNamed:imageName];
} else if (index == 2) {
image = [UIImage imageNamed:imageName];
} else if (index == 3) {
image = [UIImage imageNamed:imageName];
}
return image;
}
Please add image name in your app image folder like below.
(Note: your image name set below as in your project.)
Example Image Name :-
your condition wise you got new index but not getting images but when you set images name like same as upper images name & you got your images as index wise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With