我正在创建一个客户端服务器程序,我想从一个视图切换到另一个视图,但我在“clientserverprogram view.m”中收到错误.PLZ help.i也在五小时前问了同样的问题,但答案不是再次满意同样的错误是有关的。
“clientserverprogram view.h”
#import <UIKit/UIKit.h>
@class secondview;
@interface clientserverprogramViewController : UIViewController {
IBOutlet UITextField *name;
IBOutlet UITextView *filepath;
IBOutlet UIButton *print;
IBOutlet UIButton *settings;
IBOutlet UIButton *cancel;
IBOutlet UILabel *display;
IBOutlet secondview *secondview;
}
-(IBAction) print;
-(IBAction) settings;
-(IBAction) cancel;
@property (nonatomic , retain) IBOutlet UITextField *name;
@property (nonatomic , retain) IBOutlet UITextView *filepath;
@property (nonatomic , retain) IBOutlet UILabel *display;
@end
“clientserverprogram view.m”
#import "clientserverprogramViewController.h"
#import "secondview.h"
@implementation clientserverprogramViewController
@synthesize name ,filepath,display ;
-(IBAction) print {
NSString *str = name.text;
[display setText : str];
}
-(IBAction) settings {
[self presentModalViewController: secondview animated: YES ];
"" error: expected expression before 'secondview'""
}
-(IBAction) cancel {
exit(0);
}
- (void)dealloc {
[super dealloc];
}
@end
"secondview.h"
#import <UIKit/UIKit.h>
@interface secondview : UIViewController {
IBOutlet UIView *view;
IBOutlet UIButton *back;
}
-(IBAction) back;
@end
""secondview.m""
#import "secondview.h"
@implementation secondview
-(IBAction) back {
[self.parentViewController dismissModalViewControllerAnimated: YES];
}
- (void)dealloc {
[super dealloc];
}
@end
答案 0 :(得分:1)
我使用了你的代码,这里的问题是你的班级名称“secondview”和你正在制作的实例IBOutlet secondview * secondview是一样的。请为类名和您创建的实例使用不同的名称。
始终以类的大写字母开头,并以您创建的类实例的小写字母开头。 因此,您的类名应该是SecondView,您应该编写IBOutlet SecondView * secondView。
或者您应该使用不同的名称。它非常令人困惑。