xcode 如何在目标c中以编程方式设置图像位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8894335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:01:29  来源:igfitidea点击:

How to set image position programaticall in objective c?

objective-ciosxcodeuiimageviewuiimage

提问by Hacer sengul Akac

I want to move image to another x,y coordinates after 3 seconds I try this but I got an error like this: 2012-01-17 14:01:11.417 YapiKrediDemo[2147:207] -[Sozlesme moveImage]: unrecognized selector sent to instance 0x6e07540 My code is:

我想在 3 秒后将图像移动到另一个 x,y 坐标我尝试了这个但我得到了这样的错误:2012-01-17 14:01:11.417 YapiKrediDemo[2147:207] -[Sozlesme moveImage]: unrecognized selector sent到实例 0x6e07540 我的代码是:

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

image1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"GirisButton.png"]];
[self.view addSubview:image1];

[NSTimer scheduledTimerWithTimeInterval: 3
                                 target: self
                               selector:@selector(moveImage)
                               userInfo: nil repeats:YES];

}

- (void)moveImage:(NSTimer*)timer{

//[image1 setCenter: CGPointMake(634, 126)];
CGRect myFrame = image1.frame;
myFrame.origin.x = 634;
myFrame.origin.y = 126;
image1.frame = myFrame;
}

How can I solve this? Please help me, thanks.

我该如何解决这个问题?请帮帮我,谢谢。

回答by beryllium

You have forgotten :symbol

你忘记了:符号

selector:@selector(moveImage:)