2016-04-14 6 views
1

Also ich versuche, eine Ansicht innerhalb einer App von einem Tastendruck zu öffnen und ich die folgende Fehlermeldung angezeigt:Xcode - presentViewController NSInvalidArgumentException: Unbekannter Selektor gesendet Instanz

'NSInvalidArgumentException', reason: '-[UINavigationBar copyWithZone:]: unrecognized selector sent to instance 0x1e56aa10' 

Die Aktion für die Schaltfläche Presse:

-(IBAction)launchDirections:(id)sender 
{ 
@autoreleasepool { 

if([CLLocationManager locationServicesEnabled]){ 



     if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied 
      || [CLLocationManager authorizationStatus]==kCLAuthorizationStatusNotDetermined 
      || [CLLocationManager authorizationStatus]==kCLAuthorizationStatusRestricted ){ 

      UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"App Permission Denied" 
              message:@"To re-enable, please go to Settings and turn on Location Service for this app." 
              delegate:nil 
           cancelButtonTitle:@"OK" 
           otherButtonTitles:nil]; 
      [alert show]; 
     }else{ 
      NSLog(@"Location Services Enabled"); 
      ontracDirectionsMapViewController *directions = [[ontracDirectionsMapViewController alloc] init]; 
      directions.start = userLocation; 
      directions.end =selectedPointLocation; 

      //[self presentViewController:directions animated:NO completion:nil]; 
      //[self.navigationController pushViewController:directions animated:YES]; 

      [ self presentViewController : directions animated : YES completion :^{ 

       NSLog (@ "hello"); 

      }]; 
     } 

    } 
} 
} 

Zusätzlich habe ich die beiden Linien versucht, können Sie sehen, die kommentiert worden sind:

//[self presentViewController:directions animated:NO completion:nil]; 
//[self.navigationController pushViewController:directions animated:YES]; 

Diese machen leider keinen Unterschied. Ich bin neu in der IOS-Entwicklung und nicht sicher, wohin ich von hier aus gehen soll.

Zusätzlich gibt es eine Methode an anderer Stelle in der App copyWithZone genannt, aber selbst wenn ich das vollständig entferne, bekomme ich immer noch den Fehler mit der Referenz.

-(id)copyWithZone:(NSZone *)zone 
{ 
ontracTableMasterViewController *copy = [[ontracTableMasterViewController alloc] init]; 
copy.cookieValue = self.cookieValue; 
copy.dataObject = self.dataObject; 

return copy; 
} 
+0

'OntracDirectionsMapViewController' ist auf Storyboard? – Lion

+0

@Lion Ja, es ist, ich denke – jampez77

+0

Eine Antwort ist da. Das scheint richtig zu sein. mach das so. – Lion

Antwort

0

OK so hatten Glück ich in eine Antwort! Was ich tat, war die folgende Zeile @property (copy, nonatomic) IBOutlet UINavigationBar *directionsNavigationBar; in ontracMapViewController.h zu @property (strong, nonatomic) IBOutlet UINavigationBar *directionsNavigationBar;

den folgenden Fehler Diese erzeugen dann ändern, preferredInterfaceOrientationForPresentation must return a supported interface orientation! die ich unten durch Hinzufügen des Code gelöst:

-(BOOL)shouldAutorotate 
{ 
    return NO; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeRight; 
} 

Wie ich in der Frage sagte, ich bin Neu bei IOS dev, also nicht sicher, was zuerst passiert ist, aber das scheint jetzt gut zu funktionieren. Danke an alle für die Hilfe.

1

Wenn Sie Storyboards verwenden, setzen Sie das Storyboard-Kennung auf Ihre ontracTableMasterViewController und es instanziiert wie folgt:

ontracTableMasterViewController *oVC = (ontracTableMasterViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"YOUR_IDENTIFIER"]; 
    oVC.start = userLocation; 
    oVC.end = selectedPointLocation; 
    [self presentViewController:oVC animated:YES completion:nil]; 

Bitte das beigefügte Bild überprüfen YOUR_IDENTIFIER in Storyboard zu setzen. Hoffe, das hilft!

enter image description here

+0

Ich habe keine Option, um die Bundle-ID festzulegen:/ – jampez77

+0

Hallo @ jampepez77, was verwenden Sie? Storyboard oder .xib oder UI rein programmatisch erstellen? – Microprocessor8085

Verwandte Themen