Wypróbuj ten kod. Pomoże ci ......
W akcji kliknij przycisk Musisz wysłać swój UINavigationController & current ViewController. Ponieważ klasa NSObject nie znalazła tego kontrolera.
W swojej przycisk akcji umieścić ten kod:
[demo login_method_called:self.navigationController withCurrentViewController:self];
W swojej klasie NSObject .h umieścić ten kod:
#import <Foundation/Foundation.h>
#import "Home_ViewController.h"
@interface Method_Action_class : NSObject
- (void)login_method_called:(UINavigationController*)navigation withCurrentViewController:(UIViewController*) controller;
@end
W swojej klasie .m NSObject umieścić ten kod:
#import "Method_Action_class.h"
@implementation Method_Action_class
-(void)login_method_called:(UINavigationController*)navigation withCurrentViewController:(UIViewController*) controller
{
Home_ViewController *home = [[Home_ViewController alloc] initWithNibName:@"Home_ViewController" bundle:nil];
[navigation pushViewController:home animated:YES];
}
@end
I zbuduj swój kod.
Dwie rzeczy: Dlaczego próbujesz utworzyć instancję i wyświetlić kontroler widoku z poziomu modelu i [co próbowałeś?] (Http://www.whathaveyoutried.com) –
'AppDelegate * appDelegate = (AppDelegate *) [Delegat [UIApplication sharedApplication]]; [[appDelegate loginViewController] presentViewController: mapViewController animated: YES completion: nil]; ' Próbowałem tego kodu, ale nie działało. – Hayzum
Czy nazwa twojej klasy AppDelegate jest naprawdę" AppDelegate "? Co więcej, nie powinno być potrzeby prezentowania viewController z obiektu NSObject! –