myButton.frame不可用为什么?

时间:2010-10-15 16:58:10

标签: iphone objective-c xcode

当我尝试编写myButton时,我有一个按钮。然后,如果我点击esc按钮,则没有选项或任何智能结果。

感谢

1 个答案:

答案 0 :(得分:1)

你的代码看起来像这样吗?

@interface myViewController : UIViewController {
    UIBUtton *myButton;
}
@property (nonatomic, retain) IBOutlet UIButton *myButton

@end;

@implementation myViewController

@synthesize myButton;

- (void) someMethod
{
    //Use myButton Here?
    CGRect r = myButton.frame;
}

@end

或者这个:

@interface myViewController : UIViewController {
    // No need to declare myButton for iPhone or Mac 64-bit
}
@property (nonatomic, retain) IBOutlet UIButton *myButton

@end;

@implementation myViewController

@synthesize myButton;

- (void) someMethod
{
    //Use myButton Here?
    CGRect r = self.myButton.frame;
}

@end

如果是后者,myButton不是私有变量 - 只有属性。

相关问题