2016-05-04 16 views
1

Ich bin neu in IOS Entwicklung. In Main.storyoard habe ich ein neues viewcontroller hinzugefügt, es einer neuen Klasse ("LoginViewController") zugewiesen und eine Storyboard-ID ("loginview") zur Verfügung gestellt. Dann habe ich eine Schaltfläche auf dem Standard viewcontroller hinzugefügt und den folgenden Code versucht, die neu erstellte viewcontroller aufrufen.Ausnahme beim Aufruf eines anderen Bildschirms in IOS

NSString * storyboardName = @"Main.storyboard"; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; 
    UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"loginview"]; 
    [self presentViewController:vc animated:YES completion:nil]; 

Während das Debuggen, wenn ich auf die Schaltfläche geklickt den anderen Bildschirm anzuzeigen habe ich die folgende Ausnahme

2016-05-04 12: 04: 40,793 gcmexample [1418: 30458] * App beenden aufgrund zu abgefangene Ausnahme 'NSInvalidArgumentException', Grund: Main.storyboard 'in Bündel NSBundle (beladen) ' * erster Wurf Call-Stack' kann keinen Storyboard namens finden': (0 Corefoundation 0x0000000101150e65 exceptionPreprocess + 165 1 libobjc.A.dylib
0x0000000100840deb objc_exception_throw + 48 2 UIKit
0x0000000101c21669 - [UIStoryboard name] + 0 3 gcmexample
0x000000010033f2d6 - [Viewcontroller btnSignout:] + 86 4 UIKit
0x00000001014ff194 - [UIApplication sendAction to:: von: forEvent:] + 92 5 UIKit 0x000000010166e6fc - [UIControl sendAction: zu: forEvent:] + 67 6 UIKit 0x000000010166e9c8 - [UIControl _sendActionsForEvents: withevent:] + 311 7 UIKit 0x000000010166daf8 - [UIControl touchesEnded: withEvent:] + 601 8 UIKit 0x000000010156e49b - [UIWindow _sendTouchesForEvent:] + 835 9 UIKit 0x000000010156f1d0 - [UIWindow sendevent:] + 865 10 UIKit
0x000000010151db66 - [UIApplication sendevent:] + 263 11 UIKit
0x00000001014f7d97 _UIApplicationHandleEventQueue + 6844 12 Corefoundation 0x000000010107ca31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 17 13 Corefoundation 0x000000010107295c __CFRunLoopDoSources0 + 556 14 Corefoundation 0x0000000101071e13 __CFRunLoopRun + 867 15 Corefoundation
0x0000000101071828 CFRunLoopRunSpecific + 488 16 GraphicsServices
0x000000010492bad2 GSEventRunModal + 161 17 UIKit
0x00000001014fd610 UIApplicationMain + 171 18 gmexample
0x000000010033ffdf main + 111 19 libdyld.dylib
0x000000010388c92d start + 1 20 ???
0x0000000000000001 0x0 + 1) libC++ abi.dylib: mit abgefangene Ausnahme vom Typ endet NSException

jemand was ist der Fehler hier Kennt? Bitte helfen Sie.

+2

NSString * StoryboardName = @ "Haupt"; // ohne Erweiterung ".storyboard" –

+1

versuche dies: NSString * storyboardName = @ "Main"; –

Antwort

4

Try This: -

NSString * storyboardName = @"Main"; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; 
    UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"loginview"]; 
    [self presentViewController:vc animated:YES completion:nil]; 
+0

Danke, mein Herr. es funktioniert gut. –

+0

ur willkommen bro @ManasMaity –

1

diesen Code versuchen,

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; 
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"loginview"]; 
[self.navigationController presentViewController:vc animated:YES completion:nil]; 

hoffen, seine hilfreich

0

Verwenden Sie diesen Code wird Ihnen helfen, nevigate:

NSString * storyboardName = @"Main"; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:YoustoryboardName bundle: nil]; 
    UIViewController * vcontroll = [storyboard instantiateViewControllerWithIdentifier:@"loginview"]; 
    [self presentViewController:vcontroll animated:YES completion:nil]; 
Verwandte Themen