0
我有一个正常的视图控制器与xib,m和h文件。我希望当视图加载它时自动调用一个方法。在我当前的M文件中,我有代码调用另一个视图,这只是让我可以看到checkIfLogged方法是否工作。当应用程序加载时,它不会调用其他视图,而是保留在它自己的视图中。如何获取视图负载时调用的checkIfLogged方法?实际上,如果可能的话,我宁愿在视图被加载之前调用该方法。视图加载时未调用方法
这是我的M文件。
#import "ViewController.h"
#import "LoginView.h"
@interface ViewController()
@end
@implementation ViewController
-(void) viewDidLoad{
[self checkIfLogged];
}
- (void) checkIfLogged
{
LoginView *loginView = [[LoginView alloc] initWithNibName:@"LoginView" bundle:nil];
[loginView setModalPresentationStyle:UIModalPresentationFormSheet]; //you can change the way it is presented
[loginView setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; //you can change the animation
[self presentViewController:loginView animated:YES completion:nil]; //show the modal view
}//end checkIfLogged
@end
这里是我的.h文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
-(IBAction)checkIfLogged;
@end