喂! 我试图在按下后隐藏UIButton
这是我的.h代码:
#import <UIKit/UIKit.h>
@interface TemplateTestViewController : UIViewController { }
- (IBAction)ButtonPressed;
IBOutlet UIButton *sample; @property (nonatomic, retain) IBOutlet UIButton
*sample;
@end
这是我的.m代码:
#import "TemplateTestViewController.h"
#import "Page.h"
@implementation TemplateTestViewController
@synthesize sample;
-(IBAction) ButtonPressed{
if ( ([sample.selected=YES]))
{
sample.hidden = YES;
}
我收到四个错误,但代码不起作用。我究竟做错了什么?我是新手,所以我会非常感谢一些示例代码!
答案 0 :(得分:0)
您的.h文件中存在 @interface 声明的问题。使用以下
#import <UIKit/UIKit.h>
@interface TemplateTestViewController : UIViewController {
IBOutlet UIButton *sample;
}
@property (nonatomic, retain) IBOutlet UIButton *sample;
- (IBAction)ButtonPressed;
@end
在您的.m课程中
-(IBAction) ButtonPressed {
if(sample.selected == YES)
{
sample.hidden = YES;
}
}