博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Understanding iphone View Controllers
阅读量:7089 次
发布时间:2019-06-28

本文共 2383 字,大约阅读时间需要 7 分钟。

  • Build an iphone application
  • Write the code you care about
  • Extend in the future

Focus on data

One thing at a time

Screenfuls of content

 

navigation bar vs tab bar

navigation bar

hierarchy of content

drill down into great detail

 

tab-bar

self-contained modes

 

A Screenful of contents

slice of your application

views, data, logic

 

self-contained controller

List Controller --> Detail Controller  --> Photo Contoller

 

View Controllers in Interface Builder(storyboard)

lay out a view in interface builder

View controller is file's owner

hook up view outlet

create with -initWithNibName:bundle:

 

the second way:

View Controller in Code

override -loadview

create your views

set the view property

//subclass of UIViewController- (void) loadView{    MyView *myView = [[MyView alloc] initWithFrame:frame];    [self setView:myView];    [myView release];}

 

Hooks for Interesting Events

  • Appear

                 Load your data

  • Disappear

                Save your data

  • Interface rotation
  • Memory warnings

 

link view controller together

UINavigationController

manager a stack of view controllers

navigation bar 

 

Top view controller's view

Top view controller's title

Previous view controller't title (back bar item)

 

Modifying the navigation stack

adding a view controller

-pushViewController:animated:

remove

-popViewControllerAnimated:

 

setting up navigation

create

navigationController = [[UINavigationController alloc] init];

push the root view controller

[navigationController pushViewController:firstViewController animated:NO];

add its view to window

[window addSubView:navigationController.view];

 

Navigating

push from within a view controller on the stack

[self.navigationController pushViewController:anotherViewController animated:YES];

rarely call pop directly

Automatically invoked by the back button

 

Subclass UIViewController for each screenful

Set up in -applicationDidFinishLaunching

Push View controllers

 

TabBar

@implementation TabBarDemoDelegate- (void) applicationDidFinishLaunching:(UIApplication *) application{      [window addSubView:tabBarController.view];      [window makeKeyAndVisible];}

 

 Autoresizing your views programatically, or spring and struts

view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

 

 image

imageView.contentMode = UIViewContentModeScaleAspectFit;imageView.backgroundColor =  [UIColor blackColor];

 

 

 

转载于:https://www.cnblogs.com/grep/archive/2012/05/02/2479714.html

你可能感兴趣的文章
Ooui:在浏览器中运行.NET应用
查看>>
GitLab可完全管理Google Kubernetes Engine
查看>>
在 iOS 的 SQLite 数据库中应用 FMDB 库
查看>>
可执行镜像——开发环境的Docker化之路
查看>>
使用自选择创建团队
查看>>
基于组织目标采用合适的敏捷方法
查看>>
Spark性能调优之道——解决Spark数据倾斜(Data Skew)的N种姿势
查看>>
李彦宏宣布百度架构调整:智能云事业部升级
查看>>
NetBeans第一部分代码提交Apache
查看>>
支持医学研究的Apple开源移动框架
查看>>
使用人工智能测试软件
查看>>
InfoQ趋势报告:DevOps 和云计算
查看>>
Microsoft Edge中新的F12开发者工具
查看>>
为所有PHP-FPM容器构建单独的Nginx Docker镜像
查看>>
微软宣布Azure Functions正式支持Java
查看>>
抖音成2018年全球iOS设备上下载最多的应用\n
查看>>
IBM核心软件如何应对“互联网+”的技术挑战
查看>>
Weaveworks增加发布自动化和事件管理
查看>>
LeetCode[337] House Robber III
查看>>
Weblogic 12c 使用 WLST 新建域
查看>>