2010-08-06 8 views
0

프레임, 경계, 원점, 크기 등의 일반적인 속성에 액세스하는 데 문제가 있습니다. 내 서브 클래 싱 된 UIView 내에서 사용자가 무언가를 누르면 프레임/경계를 편집하려고합니다.서브 클래 싱 된 UIView의 속성에 액세스하는 방법?

이 오류 '프레임'이 계속 표시되지 않습니다 (이 기능에서 처음 사용).

EyeView.h

#import <UIKit/UIKit.h> 

@interface EyeView : UIView { 
    CGFloat minWidth; 
    CGFloat minHeight; 
    bool touchInWindow, touchTopLeft, touchTop, touchTopRight, touchLeft, touchRight, touchBottomLeft, touchBottom, touchBottomRight; 
    bool dragging; 
} 

@property CGFloat minWidth; 
@property CGFloat minHeight; 

- (void)checkTouchedWhere:(NSSet *)touches; 

@end 

EyeView.m

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 
    if (touches.count == 1){ 
     if (dragging == TRUE){ 
       CGPoint prevPoint1 = [[[touches allObjects] objectAtIndex:0] previousLocationInView:self]; 
       CGPoint currPoint1 = [[[touches allObjects] objectAtIndex:0] locationInView:self]; 
      CGFloat differencex = currPoint1.x - prevPoint1.x; 
      CGFloat differencey = currPoint1.y - prevPoint1.y; 
      frame.origin.x += differencex; 
      frame.origin.y += differencey; 
      [self setNeedsDisplay]; 

     } 
    } 
} 
+0

답변을 원하면 코드를 공유해야합니다. – mvds

+0

Self.frame/self.view.frame이 작동하지 않습니다 .. –

+0

문제의 코드를 알려주십시오. – SteamTrout

답변

1

self.frame 엑스 코드 3.2.3 작업된다

self.view '는 케이 (기억 대소 문자이다) UIView (UIViewController에 존재)에 존재하므로 self.view.frame이 작동하지 않습니다.

대신 [자체 프레임]을 사용해보세요.