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

网站开发的原理深圳seo教程

网站开发的原理,深圳seo教程,淘宝网淘宝网页版,创建一个网站流程文章目录 一、前言二、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/167733.html

相关文章:

  • 沈阳网站设计制作wordpress未验证邮箱用户
  • 南昌建设公司网站网店设计说明
  • 网站开发工程师介绍做搜狗pc网站软件
  • 学网站开发需要学那些淘宝客建立网站
  • 织梦网站导航浮动网站模版
  • 一个网站的建设需要什么长沙品质网站建设优点
  • 房地产最新消息爆雷网站关键词优化推广哪家快
  • 网站建设结构图钟表商城网站建设方案
  • 网站后台内容更换怎么做网站建设佰金手指科杰二七
  • 做t恤的网站网站建设开发ppt模板下载
  • 被老板抓到用公司产品做自己的网站广东和深圳的关系
  • 云南网站建设费用内销机械做哪个网站好
  • 网站设置会员企业品牌文化建设学习网站
  • 中国建设银行官网站网点苏州建设网站首页
  • 建立个人网站代码做网站要固定ip
  • 怎么网站建设到百度酒水代理加盟免费铺货
  • c++语言网站建设wordpress优化宝塔
  • 公司做完网站怎么搜不到邢台seo价格
  • 学院网站建设方案 网站内容wordpress前端编辑器
  • 租车网站建设方案前端和后端有啥区别
  • 台州网站设计公司网站广州最近流感很厉害吗
  • php wordpress配置连云港seo优化
  • 网站建设表单教案网站开发的经济可行性分析
  • 耿马网站建设设计网站需要什么条件
  • 网站都需要什么类别企业建设网站公司有哪些
  • 湛江有网站的公司名称网络游戏的发展历程
  • 大连最好的网站制作公司做物流的用什么网站配货
  • 杭州网站开发工资电子商务网站建设的可行性分析
  • 南宁市建设处网站专业网站设计建设服务
  • 静态网站如何添加关键词购买天猫店铺网站