Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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
Ios 更改背景图像并返回到Xcode中的上一个视图_Ios_Objective C - Fatal编程技术网

Ios 更改背景图像并返回到Xcode中的上一个视图

Ios 更改背景图像并返回到Xcode中的上一个视图,ios,objective-c,Ios,Objective C,我正在制作一个简单的游戏,你可以用以下代码选择背景图像: -(IBAction)FirstButtonPressed:(id)sender { UIGraphicsBeginImageContext(self.view.frame.size); [[UIImage imageNamed:@"picture4.jpg"] drawInRect:self.view.bounds]; UIImage *image = UIGraphicsGetImageFromCurrentI

我正在制作一个简单的游戏,你可以用以下代码选择背景图像:

-(IBAction)FirstButtonPressed:(id)sender
{
    UIGraphicsBeginImageContext(self.view.frame.size);
    [[UIImage imageNamed:@"picture4.jpg"] drawInRect:self.view.bounds];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    self.view.backgroundColor = [UIColor colorWithPatternImage:image];
    //[[self parentViewController] dismissModalViewControllerAnimated:YES]; <-- Not returning to previous view
}
-(iAction)第一个按钮按下:(id)发件人
{
UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage ImageName:@“picture4.jpg”]drawInRect:self.view.bounds];
UIImage*image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsSendImageContext();
self.view.backgroundColor=[UIColor WithPatternImage:image];

//[[self-parentViewController]dismissModalViewControllerAnimated:是的];你试过[self-DismissmViewController…]谢谢你,Anil!效果很好:)它几乎可以工作了,但我现在遇到了另一个问题。图像只添加到当前视图中,而不是其他视图中(应用程序中只有两个视图,我想实现的是在主视图中放置背景图像。有什么想法吗?