"x", "y" "object"를 전달한 다음이를 이동시키는 일반적인 메서드를 작성하려고합니다.Button 개체를 메서드로 전달
-(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;
}];
}
}
나는 다음과 같이 호출 할 : 현재 나는이 가지고
SecondViewController.m : 33
-(void) orientationBlockLandscape {
[self changeObjectLocations: 456 :282 : btn1] ;
[self changeObjectLocations: 391 :227 : lblTitle] ;
}
가 작동하고 있지만, 컴파일에 나는 다음과 같은 경고를 얻을 수 : 경고 : 'SecondViewController'가 '-changeObjectLocations :::'에 응답하지 않을 수 있습니다.
개체를 전달할 수 있거나 전달해야하는 더 나은 방법이 있습니까? 모든 도움에 미리 감사드립니다. 당신이 당신의 SecondViewController의 헤더에 changeObjectLocations
를 정의하지 않았다처럼
지오 ...
출력 경고를 기반으로
그게 전부입니다. 목표 -C를 처음 접했을 때 나는 항상 무언가를 잊어 버렸습니다! 감사합니다 – George
@ 문제 없습니다. 그런데 위대한 이름! ;) –