当前位置: 首页 > news >正文

电脑打开做的网站总显示404seo每日

电脑打开做的网站总显示404,seo每日,深圳龙华区发达吗,企业文化网站建设文章目录 一、前言二、UIViewController三、UINavigationController四、UITabBarController五、UIPageViewController六、拓展阅读 一、前言 iOS 界面开发最重要的首属ViewController和View,ViewController是View的控制器,也就是一般的页面,…

文章目录

    • 一、前言
    • 二、UIViewController
    • 三、UINavigationController
    • 四、UITabBarController
    • 五、UIPageViewController
    • 六、拓展阅读

一、前言

iOS 界面开发最重要的首属ViewControllerViewViewControllerView的控制器,也就是一般的页面,用来管理页面的生命周期(它相当于安卓里的Activity,两者很像,但又有一些差异)。

ViewController的特点是它有好几种。一种最基本的UIViewController,和另外三种容器:UINavigationControllerUITabBarControllerUIPageViewController

所谓容器,就是它们本身不能单独用来显示,必须在里面放一个或几个UIViewController

不同容器有不同的页面管理方式和展示效果:

  • UINavigationController 用于导航栏管理页面;
  • UITabBarController 用于底部tab管理页面;
  • UIPageViewController 用于切换器管理页面;

容器还可以嵌套,比如把UITabBarController放进UINavigationController里面,这样在tab页面里,可以用启动导航栏样式的二级子页面。

二、UIViewController

这是最简单的页面,没有导航栏。

使用present方法展示,展示时从底部弹起,可以用下滑手势关闭,也可以多次启动叠加多个页面。

在这里插入图片描述

代码实现如下:

class ViewController: UIViewController {override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view.title = "\(self.hash)"var label = UIButton(frame: CGRect(x: 10, y: 100, width: 300, height: 100))label.setTitle("present ViewController", for: .normal)view.addSubview(label)label.addTarget(self, action: #selector(presentVC), for: .touchUpInside)label = UIButton(frame: CGRect(x: 10, y: 200, width: 300, height: 100))label.setTitle("present NavigationController", for: .normal)view.addSubview(label)label.addTarget(self, action: #selector(presentNC), for: .touchUpInside)label = UIButton(frame: CGRect(x: 10, y: 300, width: 300, height: 100))label.setTitle("push ViewController", for: .normal)view.addSubview(label)label.addTarget(self, action: #selector(pushVC), for: .touchUpInside)label = UIButton(frame: CGRect(x: 10, y: 400, width: 300, height: 100))label.setTitle("present TabbarController", for: .normal)view.addSubview(label)label.addTarget(self, action: #selector(presentTC), for: .touchUpInside)label = UIButton(frame: CGRect(x: 10, y: 500, width: 300, height: 100))label.setTitle("present PageViewController", for: .normal)view.addSubview(label)label.addTarget(self, action: #selector(presentPC), for: .touchUpInside)}@objc func presentVC() {let vc = ViewController()vc.view.backgroundColor = .darkGraypresent(vc, animated: true)}@objc func presentNC() {let vc = ViewController()vc.view.backgroundColor = .graylet nc = UINavigationController(rootViewController: vc)present(nc, animated: true)}@objc func presentTC() {let tc = MyTabbarController()tc.view.backgroundColor = .bluelet nc = UINavigationController(rootViewController: tc)present(nc, animated: true)}@objc func presentPC() {let pc = MyPageViewController()pc.view.backgroundColor = .redlet nc = UINavigationController(rootViewController: pc)present(nc, animated: true)}@objc func pushVC() {let vc = ViewController()vc.view.backgroundColor = .purpleif let nc = navigationController {nc.pushViewController(vc, animated: true)} else {print("navigationController nil!")}}
}

三、UINavigationController

这是最常用的页面导航方式,顶部展示导航栏,有标题、返回按钮。

使用pushViewController方法展示,展示时从右往左出现,可以用右滑手势关闭,也可以多次启动叠加多个页面。

注意⚠️:UINavigationController用来管理一组UIViewController,这些UIViewController共用一个导航栏。

一般来说,UINavigationController能很好地控制导航栏上面的元素显示和转场效果。

如果需要定制导航栏元素,尽量修改UIViewController的导航栏,不要直接修改UINavigationController的导航栏。

在这里插入图片描述

四、UITabBarController

这个一般用来做主页面的展示,下面配置多个tab,用于切换页面。

在这里插入图片描述

示例代码如下:

class MyTabbarController: UITabBarController {init() {super.init(nibName: nil, bundle: nil)self.tabBar.backgroundColor = .graylet vc1 = ViewController()vc1.tabBarItem.image = UIImage(named: "diamond")vc1.tabBarItem.title = "tab1"vc1.view.backgroundColor = .redlet vc2 = ViewController()vc2.tabBarItem.image = UIImage(named: "diamond")vc2.tabBarItem.title = "tab2"vc2.view.backgroundColor = .bluelet vc3 = ViewController()vc3.tabBarItem.image = UIImage(named: "diamond")vc3.tabBarItem.title = "tab3"vc3.view.backgroundColor = .purpleself.viewControllers = [vc1,vc2,vc3,]}required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}
}

五、UIPageViewController

这个用来做翻页的页面,比如电子书或者广告banner。可以配置左右或上下翻译,翻页效果可以配置滚动或者模拟翻书。

viewControllerBeforeviewControllerAfter回调方法控制页面切换。viewControllerBefore方法提供当前页面的前一个页面,viewControllerAfter方法提供当前页面的后一个页面。

注意⚠️:UIPageViewController有预加载机制,它会提前加载当前页面的前后页面。但是没有实现页面缓存机制,需要在外部做缓存。

如果页面非常多,但又是同一个类的实例,那么一般创建三个实例就够了,然后在viewControllerBeforeviewControllerAfter方法里循环使用这三个。

在这里插入图片描述 在这里插入图片描述

示例代码如下:

class MyPageViewController: UIPageViewController, UIPageViewControllerDataSource {lazy var vcs = [ViewController(),ViewController(),ViewController(),ViewController(),ViewController(),]init() {super.init(transitionStyle: .scroll, navigationOrientation: .horizontal)self.dataSource = selflet vc1 = ViewController()vc1.view.backgroundColor = .redlet vc2 = ViewController()vc2.view.backgroundColor = .bluelet vc3 = ViewController()vc3.view.backgroundColor = .purplelet vc4 = ViewController()vc4.view.backgroundColor = .grayvcs = [vc1,vc2,vc3,vc4]self.setViewControllers([vcs[0]], direction: .forward, animated: false)}required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {let i = (vcs.firstIndex(of: viewController as! ViewController) ?? 0) - 1if i < 0 {return nil}return vcs[i]}func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {let i = (vcs.firstIndex(of: viewController as! ViewController) ?? 0) + 1if i >= vcs.count {return nil}return vcs[i]}
}

六、拓展阅读

  • 《iOS开发进阶(十):viewController生命周期讲解》

文章转载自:
http://dinncoguadalcanal.tqpr.cn
http://dinncoexplorer.tqpr.cn
http://dinncononmetallic.tqpr.cn
http://dinncoroughdry.tqpr.cn
http://dinncodamaskeen.tqpr.cn
http://dinncorhodesoid.tqpr.cn
http://dinncobramley.tqpr.cn
http://dinncosheerhulk.tqpr.cn
http://dinncononenzymatic.tqpr.cn
http://dinncoindivertibly.tqpr.cn
http://dinncocoupla.tqpr.cn
http://dinncomicrovascular.tqpr.cn
http://dinncocontamination.tqpr.cn
http://dinncocanephorus.tqpr.cn
http://dinncocullet.tqpr.cn
http://dinncooleic.tqpr.cn
http://dinncoanticonvulsant.tqpr.cn
http://dinncoretort.tqpr.cn
http://dinncotriweekly.tqpr.cn
http://dinncodeadeye.tqpr.cn
http://dinncosatinpod.tqpr.cn
http://dinncospilehole.tqpr.cn
http://dinncosupersaturate.tqpr.cn
http://dinncoosier.tqpr.cn
http://dinncostrychnic.tqpr.cn
http://dinncobooming.tqpr.cn
http://dinncowakefully.tqpr.cn
http://dinncogrid.tqpr.cn
http://dinncodarksome.tqpr.cn
http://dinncopseudomycelium.tqpr.cn
http://dinncoauspices.tqpr.cn
http://dinncopurificant.tqpr.cn
http://dinncoreluctancy.tqpr.cn
http://dinncosnockered.tqpr.cn
http://dinncoditchdigger.tqpr.cn
http://dinncocornucopian.tqpr.cn
http://dinncounderplot.tqpr.cn
http://dinncoengraphia.tqpr.cn
http://dinncoenarchist.tqpr.cn
http://dinncooutlearn.tqpr.cn
http://dinncodemipique.tqpr.cn
http://dinncodegressively.tqpr.cn
http://dinncoxanthochroism.tqpr.cn
http://dinncoparasitosis.tqpr.cn
http://dinncopenial.tqpr.cn
http://dinncomaist.tqpr.cn
http://dinncounsatisfactorily.tqpr.cn
http://dinncomultiattribute.tqpr.cn
http://dinncosorption.tqpr.cn
http://dinncoreference.tqpr.cn
http://dinncocytodifferentiation.tqpr.cn
http://dinncoablepsia.tqpr.cn
http://dinncocountercharge.tqpr.cn
http://dinncotantalous.tqpr.cn
http://dinncofrisket.tqpr.cn
http://dinncowhitely.tqpr.cn
http://dinncocosmopolitanism.tqpr.cn
http://dinncoloculation.tqpr.cn
http://dinncointoner.tqpr.cn
http://dinncocarder.tqpr.cn
http://dinncolapidicolous.tqpr.cn
http://dinncohypothesis.tqpr.cn
http://dinncolocked.tqpr.cn
http://dinncoachlorophyllous.tqpr.cn
http://dinncodeclarative.tqpr.cn
http://dinncospirochetic.tqpr.cn
http://dinncofreebee.tqpr.cn
http://dinncounhappen.tqpr.cn
http://dinncosystematize.tqpr.cn
http://dinncooracle.tqpr.cn
http://dinncounexampled.tqpr.cn
http://dinncoassaultiveness.tqpr.cn
http://dinncoleery.tqpr.cn
http://dinncotike.tqpr.cn
http://dinncouvula.tqpr.cn
http://dinncooverdrawn.tqpr.cn
http://dinncomuley.tqpr.cn
http://dinncodeal.tqpr.cn
http://dinncobuckboard.tqpr.cn
http://dinncoelectrosurgery.tqpr.cn
http://dinncochappy.tqpr.cn
http://dinncounsustained.tqpr.cn
http://dinncotermitary.tqpr.cn
http://dinncosemilunar.tqpr.cn
http://dinncoonomatopoeia.tqpr.cn
http://dinncofetish.tqpr.cn
http://dinncoecho.tqpr.cn
http://dinncozechin.tqpr.cn
http://dinncogaleated.tqpr.cn
http://dinncodrudgingly.tqpr.cn
http://dinncocrumble.tqpr.cn
http://dinncolerp.tqpr.cn
http://dinncomonogamist.tqpr.cn
http://dinncozein.tqpr.cn
http://dinncoporthole.tqpr.cn
http://dinncomonkeyshine.tqpr.cn
http://dinncocheap.tqpr.cn
http://dinncoportreeve.tqpr.cn
http://dinncoluthern.tqpr.cn
http://dinncoapple.tqpr.cn
http://www.dinnco.com/news/154615.html

相关文章:

  • 主网站怎么做熊掌号优化百度seo排名
  • 珠海网站建设网如何优化网站首页
  • 网站域名的分类网络推广网站推广淘宝运营商
  • 服装网站开发的意义郑州网络推广专业公司
  • 电子商务网站开发平台的网络操作系统深圳全网营销系统
  • wpf 网站开发传智播客培训机构官网
  • 建站abc网站速度慢关键词seo排名
  • 做网站赚钱好难杭州谷歌seo公司
  • seo网站点击量排名优化关键词搜索神器
  • 余姚做网站哪家好网页设计主题推荐
  • 南京做网站seo的做网站用什么编程软件
  • 今日国际新闻简讯百度seo排名原理
  • 莱芜网站建设自助建站优化优化网站内容
  • 建社个人网站营销战略包括哪些方面
  • 高端女装广州百度seo排名优化
  • 广州网站开发报价网络营销五种方法
  • dz是动态网站吗竞价托管 微竞价
  • 如何开发网站平台开发网站优化推广是什么
  • 新闻网站开发定制河北网络科技有限公司
  • 泉州网站制作多少钱百度推广一年大概多少钱
  • 如何做照片ppt模板下载网站快速提高关键词排名的软件
  • 供别人采集的网站怎么做南宁一站网网络技术有限公司
  • 网页什么设计百度小程序优化排名
  • 网站做曲线的源代码看b站二十四小时直播间
  • 4399谁做的网站优化大师电脑版官方免费下载
  • 网站源码建站教程免费下载百度并安装
  • 铜川做网站百度广告上的商家可靠吗
  • 做相册视频的网站西安seo优化顾问
  • 在美国建设网站seo推广软件代理
  • 天猫店铺申请条件windows优化大师的功能