Xcode建立文件夹
- 如果仅是在xcode里创建,那文件夹不会在存在finder里,实际上相关文件还是存在一个目录下
- 需要在Xcode里左下角,”add new file to ….project” –> create new folder –> add,这样创建的文件夹可以存在finder里
指定启动视图
指定启动的storyboard
在info.plist文件中指定了所启动的storyboard是哪个。也可以另建新的storybord

指定启动的视图控制器
箭头指向

配置属性

UINavigationController
导航视图顶部自定义
UINavigationItem + UIBarbuttonItem

UITablViewController
TableView视图连接的设置

也可以在左侧导航栏中,ctrl + drag tableview to the controller,进行连接datasource and delegate

TableViewCell
设置静态tableViewCell(cell可以复制粘贴)

Static TableViewCell

Dynamic TableViewCell

UITabBarController
新建new tab
按住ctrl 键拖入到新的视图,选择 Relationship Segue — view controllers

视图的跳转和连接
创建新的rootViewController

视图跳转 - 模态视图
呈现使用present
[self presentViewController:modalVC animated:YES completion:nil];
退出使用dissmiss
- (void)dismissAction{
[self dismissViewControllerAnimated:YES completion:nil];
}
视图跳转 - push视图
呈现用导航视图push/show
- (void)pushAction{
PushViewController *pushVC = [[PushViewController alloc] init];
[self.navigationController pushViewController:pushVC animated:YES];
//[self.navigationController showViewController:pushVC sender:nil];
RootViewController *rootVC = (RootViewController *)self.tabBarController;
[rootVC showTabBar:NO];
}    
退出用pop 的三种方式
- (void)popAction{
    // 回到上级视图
    [self.navigationController popViewControllerAnimated:YES];
    // 跳转到某视图
    //[self.navigationController popToViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>]
    // 跳转到根视图
    //[self.navigationController popToRootViewControllerAnimated:YES];
}
无Segue连接 - StoryboardId
let vc = storyboard!.instantiateViewControllerWithIdentifier("UserContent")as! UserContentViewController  
vc.data = data  
presentViewController(vc, animated: true, completion: nil)

Segue自动连接(button)
- 点住Button or Cell,按住ctrl,向新的viewController拖动,选择segue模式,点击后不需任何方法,会自动跳转到目的视图
- 可以在prepareForSegue中进行数据传递(optional)
- 从新视图的返回,使用如下代码:
| 1 | self.dismissModalViewControllerAnimated(true) | 
or
[self.navigationController popViewControllerAnimated:YES];
Segue手动连接(login)

//一般在这里给下一个控制器传值这个sender是当初performSegueWithIdentifier方法传入的sender
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
UIViewController *contactVc = segue.destinationViewController;
contactVc.title = [NSString stringWithFormat:@"%@的联系人列表",self.nameField.text];
 }
 .........
 - (IBAction)loginAction {
 [self performSegueWithIdentifier:@"LoginToContact" sender:nil];}
视图中传值
自动跳转传值
在第一个视图中创建新视图的同时,就将其属性配置好1
2
3
4
5
6@IBOutlet var input:UITextField
@IBAction func nextBtn{
let vc = MyViewController(nibName:"MyViewController",bundle:nil)
vc.labelContent = input.text
}
self.presentModalViewController(vc,animated:true)
在第二个视图中1
2
3
4var labelContent:String = ""
func viewDidLoad(){
myLabel.text = labelContent
}
返回时传值:在第二个视图中,通过如下代码,访问到前一个视图
| 1 | self.parentViewController | 
Segue跳转传值
//一般在这里给下一个控制器传值这个sender是当初performSegueWithIdentifier方法传入的sender
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//1.取得目标控制器
UIViewController *contactVc = segue.destinationViewController;
//2.设置标题(传值)
contactVc.title = [NSString stringWithFormat:@"%@的联系人列表",self.nameField.text];
}
.........
- (IBAction)loginAction {
[self performSegueWithIdentifier:@"LoginToContact" sender:nil];}
UI Element
UIButton


UIBarbutton

UITextfield

若干UI元素重合时的排序
