自定义NavigationBar在swift中(Custom NavigationBar in swift)

编程入门 行业动态 更新时间:2024-10-21 19:34:09
自定义NavigationBar在swift中(Custom NavigationBar in swift)

我对swift和ios非常陌生,所以我需要对以下概念进行清理

我创建了一个视图,其中一个按钮具有后退箭头的背景图像,按钮操作我将返回到之前的控制器,即登录,这样做是否安全,而不是使用NavigationController?

@IBAction func onBackPressed(sender: AnyObject) { let aaa : Login = self.storyboard?.instantiateViewControllerWithIdentifier("Login") as! Login self.presentViewController(aaa, animated: true, completion: nil) }

谢谢

I am very much new to swift and ios so i need my doubts to be cleared for the below concept

I have created a view with a button having background image of back arrow and on button action i am going back to the previous controller which is the Login, is it safe to do it this way instead of using NavigationController??

@IBAction func onBackPressed(sender: AnyObject) { let aaa : Login = self.storyboard?.instantiateViewControllerWithIdentifier("Login") as! Login self.presentViewController(aaa, animated: true, completion: nil) }

Thanks

最满意答案

当您想要推送到下一个View Controller时,导航控制器是最佳选择。

(即)导航控制器 - >视图控制器 - >视图控制器[推送]。

所以我的建议是,如果你想回到以前的视图控制器使用导航控制器

当您想要提供新的View Controller时 ,不需要时间。

Navigation controller is best when you want to push to next View Controller.

(i.e) Navigation Controller ->View Controller ->View Controller[for Push].

So my suggestion is if you want to come back to previous view controller use Navigation Controller

When you want to present a new View Controller that time no need.

更多推荐

本文发布于:2023-08-06 04:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1444457.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   NavigationBar   Custom   swift

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!