2011-01-19 2 views
1

iPhone/Objective-C 프로그래밍을 처음 사용합니다. 나는 UIImageView * myImage x, y, 너비, 높이 CGRect 값 (2020100100) 또는 무엇이든 사용하여 설정되어;copy uiimageview from CGPoint

Q1) 다음과 같이하면 왜 원점 값을 CGPoint로 가져올 수 없습니까?

CGPoint myPoint = myImage.frame.origin; 

NSLog(@"X:%f Y:%f",mypoint.x, mypoint.y) // Prints X: 0.0 and Y: 0.0 instead of X:20.0 and Y: 20.o 
NSLog(@"X:%f Y:%f",myImage.frame.origin.x, myImage.frame.origin.x) // Prints X: 20.0 and Y: 20.0 

NSLog 위의 문은 myPoint에 대한 예상 값을 인쇄하지만 myImage.frame.origin에 대한 올바른 값을 출력하지 않습니다. 왜?

Q2) 왜 @property를 CGPoint로 설정할 수 없습니까?

답변

2

1) 당신이 시도 유무 :

나는이 같은 속성으로 당신의 CGPoint을 할 수 있어야 것으로 나타났습니다) 솜 테스트 후
CGPoint myPoint = CGPointMake(myImage.fram.origin.x, myImage.frame.origin.y); 

2 :

@interface MyClass : NSObject { 

CGPoint myPoint; 
... 
} 
@property (nonatomic) CGPoint myPoint; 

... 
@end 

그리고 :

@implementation MyClass 
@synthesize myPoint; 

... 

@end 

은 나를 위해 일한 것을.

(필자는 (비 원자)를 아직 이해하지 못했지만 필요하다면 작동하지만 ...)