AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
goes on like normal app..........
@end
第一视图控制器.h
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIImageView *bGround;
- (IBAction)settingsPressed:(id)sender;
- (IBAction)startPressed:(id)sender;
@end
@class SecondViewController;
@interface SecondViewController : UIViewController
@property(strong,nonatomic)SecondViewController *secondViewController;
@end
第一视图控制器.m
#import "FirstViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)settingsPressed:(id)sender {
在这一行上它说“在'FirstViewController'类型的对象上找不到属性'secondViewController' 这是直接下面的行。
self.secondViewController =
[[SecondViewController alloc] initWithNibName:@"SecondViewController"
bundle:nil];
它与下面一行的最后一个警告相同。
[self presentViewController:self.secondViewController animated:YES completion:nil];
}
- (IBAction)startPressed:(id)sender {
}
@end
SecondViewController.h
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
@end
第二视图控制器.m
#import "SecondViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end