Note that there are some explanatory texts on larger screens.

plurals
  1. POset iphone wallpaper with array of buttons objective c
    primarykey
    data
    text
    <p>Hi. I am developing an app and I would like to set the background in the app itself. Now I created an array of buttons using a for loop and setting tags, but for some reason when I click the buttons nothing happens.</p> <p>This is where the buttons are created:</p> <pre><code>-(void)showSettings { [[objc_getClass("DreamBoard") sharedInstance] hideAllExcept:mainView]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.5]; if(toggled){ photos = [[NSArray arrayWithObjects: [UIImage imageWithContentsOfFile:@"/var/mobile/Library/iZoon/Images/Wallpapers/Wallpaper1.png"], [UIImage imageWithContentsOfFile:@"/var/mobile/Library/iZoon/Images/Wallpapers/Wallpaper2.png"], [UIImage imageWithContentsOfFile:@"/var/mobile/Library/iZoon/Images/Wallpapers/Wallpaper3.png"], [UIImage imageWithContentsOfFile:@"/var/mobile/Library/iZoon/Images/Wallpapers/Wallpaper4.png"], nil] retain]; w=0; for ( UIImage *image in photos ) { for (l = 0; l&lt;(int)photos.count; l++) { wallpaperButton = [[UIButton alloc] initWithFrame:CGRectMake(5,130+150*w,150,150)]; wallpaperButton.tag = l; [wallpaperButton setImage:image forState:UIControlStateNormal]; [wallpaperButton addTarget:self action:@selector(setWallpaper) forControlEvents:UIControlEventTouchDown]; [settingsMenu addSubview: wallpaperButton]; [wallpaperButton release]; } w++; } </code></pre> <p>Here is the function to set the wallpaper:</p> <pre><code>-(void)setWallpaper { UIImageView *bgView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)]; if ([wallpaperButton tag] == 1) { bgView.image = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/iZoon/Images/Wallpapers/Wallpaper1.png"]; } else if ([wallpaperButton tag] == 0) { bgView.image = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/iZoon/Wallpapers/Wallpaper2.png"]; } else if ([wallpaperButton tag] == 2) { bgView.image = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/iZoon/ Wallpapers/Wallpaper3.png"]; } else if ([wallpaperButton tag] == 3) { bgView.image = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/iZoon/Wallpapers/Wallpaper4.png"]; } [mainView insertSubview:bgView atIndex:0]; [bgView release]; </code></pre> <p>}</p> <p>Now the buttons display correctly but they don't do anything. Any help is appreciated. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload