【发布时间】:2011-09-27 01:12:58
【问题描述】:
我正在尝试编写一个通用方法,它允许我传递以下内容:“x”、“y”、“object”,然后让它移动。目前我有这个:
-(void) changeObjectLocations: (integer_t) xSpot: (integer_t) ySpot: (id) sender {
if (![sender isKindOfClass:[UIButton class]])
{
UIButton *myObject = (UIButton *)sender;
[UIView animateWithDuration:1.5
animations:^{
CGRect newFrame = myObject.frame;
newFrame.origin.x = xSpot;
newFrame.origin.y = ySpot;
myObject.frame = newFrame;
}];
}
else if (![sender isKindOfClass:[UILabel class]])
{
UILabel *myObject = (UILabel *)sender;
[UIView animateWithDuration:1.5 animations:^{
CGRect newFrame = myObject.frame;
newFrame.origin.x = xSpot;
newFrame.origin.y = ySpot;
myObject.frame = newFrame;
}];
}
}
然后我想这样称呼它:
-(void) orientationBlockLandscape {
[self changeObjectLocations: 456 :282 : btn1] ;
[self changeObjectLocations: 391 :227 : lblTitle] ;
}
虽然它正在工作,但在编译时我收到以下警告:
SecondViewController.m:33:警告:“SecondViewController”可能不会响应“-changeObjectLocations:::”
有没有更好的方法可以/应该传递对象?提前感谢您提供的所有帮助。
地理...
【问题讨论】:
标签: objective-c xcode ipad ios4