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

网站开发的原理做百度企业网站有什么好处

网站开发的原理,做百度企业网站有什么好处,阿里云官方网站,wordpress电影站数据下载文章目录 一、前言二、UIViewController三、UINavigationController四、UITabBarController五、UIPageViewController六、拓展阅读 一、前言 iOS 界面开发最重要的首属ViewController和View#xff0c;ViewController是View的控制器#xff0c;也就是一般的页面#xff0c;… 文章目录 一、前言二、UIViewController三、UINavigationController四、UITabBarController五、UIPageViewController六、拓展阅读 一、前言 iOS 界面开发最重要的首属ViewController和ViewViewController是View的控制器也就是一般的页面用来管理页面的生命周期它相当于安卓里的Activity两者很像但又有一些差异。 ViewController的特点是它有好几种。一种最基本的UIViewController和另外三种容器UINavigationController、UITabBarController、UIPageViewController。 所谓容器就是它们本身不能单独用来显示必须在里面放一个或几个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 tab1vc1.view.backgroundColor .redlet vc2 ViewController()vc2.tabBarItem.image UIImage(named: diamond)vc2.tabBarItem.title tab2vc2.view.backgroundColor .bluelet vc3 ViewController()vc3.tabBarItem.image UIImage(named: diamond)vc3.tabBarItem.title tab3vc3.view.backgroundColor .purpleself.viewControllers [vc1,vc2,vc3,]}required init?(coder: NSCoder) {fatalError(init(coder:) has not been implemented)} }五、UIPageViewController 这个用来做翻页的页面比如电子书或者广告banner。可以配置左右或上下翻译翻页效果可以配置滚动或者模拟翻书。 用viewControllerBefore和viewControllerAfter回调方法控制页面切换。viewControllerBefore方法提供当前页面的前一个页面viewControllerAfter方法提供当前页面的后一个页面。 注意⚠️UIPageViewController有预加载机制它会提前加载当前页面的前后页面。但是没有实现页面缓存机制需要在外部做缓存。 如果页面非常多但又是同一个类的实例那么一般创建三个实例就够了然后在viewControllerBefore和viewControllerAfter方法里循环使用这三个。 示例代码如下 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://www.dnsts.com.cn/news/136019.html

相关文章:

  • 网站推他网站网站怎么做可以被收录
  • 网站建设技术jsp课程设计天元建设集团有限公司商票
  • 单页网站源码东莞住建局
  • 陕西省住房和城乡建设厅网站上查询网站视频站建设教程和
  • 网站排名查询软件alexa如何开发安卓app
  • 淘宝客怎么做推广深圳网站建设方案优化
  • 网站托管服务 优帮云创意旅行社wordpress
  • 后台给网站做关键字dw软件做二级连接网站
  • 淘宝客建网站怎么做给大家分享个永久免费的云服务器
  • 2016响应式网站模板网页设计与制作教程第五版课后答案
  • 黄冈网站建设与推广哪家好网站开发页面大小适应屏幕
  • 有了网站怎么写文章广东网站备案要求
  • 网络科技网站把做的网站发布打万维网上
  • 怎么做系统软件网站没有域名怎么访问网站
  • 靖江建设行业协会网站国外做的好的电商网站推荐
  • wordpress做自建站wordpress主题修改教程
  • 手机版网站推荐昆明网站建设yn119
  • 邱县网站建设潍坊网站关键字优化
  • 莱芜区组织部网站免费网站建设社区
  • ppt做的好的有哪些网站有哪些阿里云免费空间
  • 电子商务网站建设财务分析应用公园app的功能介绍
  • 兰州需要做网站的公司有哪些黄南州wap网站建设公司
  • 个人网站备案要求北京网站seo排名优化
  • 自己搭建服务器访问国外网站网页的制作公司
  • 科技公司网站设计公司获取网站服务器信息
  • 太和县住房和城乡建设局网站滕州网站优化
  • 代刷网站只做软件摄影集 wordpress
  • 长沙哪家做网站设计好网站建设制作一个网站的费用
  • 适合做浏览器主页的网站dw做的网站如何上传云服务器
  • 网站建设收费分几次wordpress 文章 顺序