如何访问子类UIView属性?

时间:2010-08-06 13:32:56

标签: iphone

我在访问框架,边界,原点,大小等常用属性时遇到问题。在我的子类UIView中,我正在尝试在用户按下某些内容时编辑框架/边界。

我一直得到这个错误'frame'未声明(首先在此函数中使用)。

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];

        }
    }
}

1 个答案:

答案 0 :(得分:1)

self.frame正在使用Xcode 3.2.3(请记住区分大小写)

UIView中不存在

self.view(它存在于UIViewController中),因此self.view.frame将无效。

尝试[自我框架]。