0

我在 .m 文件中有此代码:

- (void) viewDidAppear:(BOOL)animated {
    // Animations
    [UIView animateWithDuration:0.2
                          delay:0
                        options:UIViewAnimationCurveEaseInOut
                     animations:^{
                         self.Button1.alpha = 1; 
                     } 
                     completion:^ (BOOL finished){}
     ];
}

但这行给了我错误:

self.Button1.alpha = 1; 

它说 :

member reference base type 'void' is not a structure or union

这是什么意思?

更新:这是我的 .h 文件

@interface ViewController : UIViewController

- (IBAction)Button1;

@end
4

2 回答 2

2

Button 应该是 aIBOutlet而不是IBAction. 请更正它并更新 XIB 参考,你应该很好。

例如

@property (nonatomic, weak) IBOutlet UIButton *button1;-> 如果您使用的是 UIButton,则将此链接到 UIButton 是 XIB。

于 2013-09-10T16:04:02.567 回答
1

您需要声明@property (nonatomic, weak) IBOutlet UIButton *button1;然后从情节提要中连接它,这将为您提供指向它的指针。此外,请遵守在开头使用小写字母命名动作和对象的约定。大写应保留给类/类别。

于 2013-09-10T16:06:04.697 回答