Ich bin neu in iOS. Und ich möchte Navigationscontroller in meiner Anwendung verwenden, aber ich habe keine Ahnung, wie es geht. So kann mich jeder Schritt für Schritt zur Navigation in meiner Anwendung führen.UINavigationController in iOS programmatisch erstellen
Antwort
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ImageViewController2 *dealVC = (ImageViewController2 *)[storyboard instantiateViewControllerWithIdentifier:@"ImageViewController2"];
[self.navigationController pushViewController:dealVC animated:YES];
wo ImageViewController2 einen Klassennamen
Sie können UINavigationController in Appdelegate erstellen und Ihren ersten Viewcontroller darauf einstellen.
Wenn Sie alles programmgesteuert erstellen möchten, müssen Sie dies in AppDelegate tun.
Aber wenn Sie nicht wollen, es programmatisch zu tun, dann wählen Sie einfach die Viewcontroller in der Storyboard dann Menüoptionen wählen:
Editor-> Embed In -> Navigation Controller
In appDelegate.h
@property (strong, nonatomic) UINavigationController *navController;
und stellen die Delegierten UINavigationControllerDelegate
und Synthetisierung Objekt in appDelegate.m
, jetzt
appDelegate.m
Sie Navigation-Controller in didFinishLaunchingWithOptions
Methode
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
frstVwCntlr = [[firstViewController alloc] initWithNibName:@"firstViewController" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:self.frstVwCntlr];
self.window.rootViewController = self.navController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
In dem obigen Code, Ihre firstViewController zu UINavigationController
und UINavigationController
hinzugefügt UIWindow
wie
self.window.rootViewController = self.navController
Hoffe, das kann Ihnen helfen
Wenn es wertvoll ist für Sie als Bitte wie die Antwort @ user3418619 – Sanawaj
So erstellen Sie einen UINavigationController programmatisch ohne Verwendung von Storyboards, zu Ihrem App-Delegaten gehen und folgendermaßen vorgehen. Erstellen Sie zwei Eigenschaften, Fenster und Viewcontroller
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor=[UIColor clearColor];
self.viewController = [[YourFirstViewController alloc] initWithNibName:@"YourFirstViewController" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:self.viewController];
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
// Override point for customization after application launch.
return YES;
}
Hier ist der Code, den Sie in AppDelegate schreiben soll.
UIViewController *vc=[[UIViewController alloc]initWithNibName:@"vc1" bundle:nil];
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
view.backgroundColor=[UIColor redColor];
[vc setView:view];
self.navme=[[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = self.navme;
für Swift 3.0 mit Filter:
let desiredController = self.navigationController!.viewControllers.filter { $0 is YourController }.first!
self.navigationController!.popToViewController(desiredController, animated: true)
- 1. ios uinavigationcontroller in uiviewcontroller
- 2. UISegmentedControl nicht auf UINavigationController zentriert, wenn programmatisch
- 3. IOS rightBarButtonItem auf UINavigationController in swift
- 4. iOS 7 UINavigationController Push-Animation Schatten
- 5. iOS 7 benutzerdefinierte Übergänge mit UINavigationController
- 6. Wie kann ich meine UINavigationController-Elemente programmatisch neu anordnen?
- 7. iOS: Update Einschränkungen programmatisch
- 8. IOS 7: UINavigationBar nicht synchron mit UINavigationController
- 9. iOS 7 uinavigationcontroller wie Swipe erkennen?
- 10. Ein UINavigationController in der Masteransicht eines UISplitViewControllers in iOS 8
- 11. iOS 8 UINavigationController deaktivieren Zurück Taste
- 12. iOS 7 UINavigationController NavBar pro Controller Farbanimation
- 13. iOS Swift App SceneKit mit UINavigationController
- 14. Erstellen eines TableView programmatisch mit Objective-C iOS
- 15. Wenn "programmatisch" UINavigationController und UITabBarController erstellen, wie spreche ich ihre Funktionen (wie viewWillAppear?)
- 16. Abmelden von Facebook iOS programmatisch
- 17. ändern Imageview Höhe ios programmatisch
- 18. erstellen programmatisch GStringExpression
- 19. Programmatisch definierte Einschränkungen Swift iOS
- 20. iOS: Tab programmatisch ändern - Storyboard
- 21. XtraScheduler Termin programmatisch erstellen
- 22. iOS UINavigationController-ähnliches Verhalten in einem Teilbildschirmbereich (2016)
- 23. Programmatisch rekursiv Verzeichnis erstellen
- 24. Programmatisch PDF-Fotoalben erstellen
- 25. XML-Datei erstellen programmatisch
- 26. programmatisch Layer-Liste erstellen
- 27. Wie fangen Sie __cxa_throw programmatisch in iOS
- 28. Click-Ereignis auf UIImageView programmatisch in ios
- 29. Wie Seitenverhältnis Einschränkung programmatisch in ios setzen
- 30. Batterieverbrauch einzelner Anwendung programmatisch in ios
Googeln Sie würde helfen – Rajesh
haben u in stroyborad oder xib in Ihrem Xcode verwendet –
[Navigation Controller Programetically] (http: //www.idev101. com/lernen/navigation_controllers.html) [Navigation Controller in Storyboard] (http://www.appcoda.com/use-storyboards-to-build-navigation-controller-and-table-view/) –