类" ViewController"的重复接口定义

时间:2015-01-16 21:10:22

标签: ios objective-c

在最后一行,我收到错误:Duplicate interface definition for class "ViewController".我想做一个IBAction。什么是错?我能做什么?请帮帮我。

//
//  ViewController.h


#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
@interface SimpleEmailViewController : UIViewController <MFMailComposeViewControllerDelegate>
- (IBAction)showEmail:(id)sender;
@end
@interface ViewController : UIViewController <MFMessageComposeViewControllerDelegate> {

}
-(IBAction)sendMessage:(id)sender;
- (IBAction)showEmail:(id)sender;
@property (nonatomic, strong) IBOutlet UIWebView *site   ;
- (IBAction)call:(id)sender;
@property (retain, nonatomic) IBOutlet UIButton *myBotton;
@end
@interface ViewController : UIViewController**i**

2 个答案:

答案 0 :(得分:2)

问题正是错误所指出的。您定义了@interface viewController两次。将其名称更改为其他名称。作为旁注,用名称apple已经使用的名称命名是一个可怕的想法。您应该将viewController更改为其他内容,更具描述性,例如mailViewController或setupViewController。使用Apple定义的名称时可能会发生奇怪的事情。

@interface FSMainiPadViewController : UIViewController

答案 1 :(得分:1)

为什么不像这样简单?

//  ViewController.h
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>

@interface ViewController : UIViewController <MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate>
   // Actions
   - (IBAction)showEmail:(id)sender;
   - (IBAction)sendMessage:(id)sender;
   - (IBAction)call:(id)sender;

   // Properties
   @property (nonatomic, strong) IBOutlet UIWebView *site;
   @property (retain, nonatomic) IBOutlet UIButton *myBotton;
@end