Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
设置带有按钮阵列的iphone壁纸目标c_Iphone_Objective C_Tags_Uibutton_Wallpaper - Fatal编程技术网

设置带有按钮阵列的iphone壁纸目标c

设置带有按钮阵列的iphone壁纸目标c,iphone,objective-c,tags,uibutton,wallpaper,Iphone,Objective C,Tags,Uibutton,Wallpaper,嗨。我正在开发一个应用程序,我想在应用程序本身设置背景。 现在,我使用for循环和设置标记创建了一个按钮数组,但由于某种原因,当我单击按钮时,什么也没有发生 这是创建按钮的地方: -(void)showSettings { [[objc_getClass("DreamBoard") sharedInstance] hideAllExcept:mainView]; [UIView beginAnimations:nil context:nil]; [UIView setAnimatio

嗨。我正在开发一个应用程序,我想在应用程序本身设置背景。 现在,我使用for循环和设置标记创建了一个按钮数组,但由于某种原因,当我单击按钮时,什么也没有发生

这是创建按钮的地方:

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

现在按钮显示正确,但没有任何作用。
感谢您的帮助。谢谢。

添加NSLog语句以查看是否正在调用setWallpaper方法。如果是,那么我认为这可能是一个解决方案:

如果您只是将图像添加到您的XCode项目中,您只需按图像的名称即可获得它们。将图像拖动到项目中时,请确保选中“将文件复制到项目文件夹(如果需要)”框。然后,要获得图像,只需执行以下操作:

if ([wallpaperButton tag] == 1) {
    bgView.image = [UIImage imageNamed:@"Wallpaper1.png"];
}
.
.
.
[self.view addSubview:bgView];

此外,您应该注意,除非您的应用程序隐藏了状态栏(带有电池和时钟的状态栏),否则您的图像实际上应该具有460的高度,因为20px已被该高度所耗尽。

谢谢!添加NSLog后,我能够调整并找出错误所在。我以前从未真正使用过它。非常感谢。
if ([wallpaperButton tag] == 1) {
    bgView.image = [UIImage imageNamed:@"Wallpaper1.png"];
}
.
.
.
[self.view addSubview:bgView];