7.StoryBoard初学习1

来源:互联网 发布:虾米音乐软件 编辑:程序博客网 时间:2024/05/16 08:28

1.设置初始view


2.给viewController设置navagatoion


3.Segue 使用之弹出view

 A---->B

a.右击A上边的某按钮拖动到B上在弹出的框种选择Modal(模态转换)

b.给模态转换命名:


dissmiss B

a.B 设置Done 按钮

b.B中添加代理方法

@class B;


@protocol BViewControllerDelegate <NSObject>

- (void)BDidSave:(B *)controller;

@end


c.B中添加Done按钮的IBAction方法:

- (IBAction)done:(id)sender;

d.在StoryBoard中Done按钮右击拖动到,选择Done的IBAction方法。

e.在B的.m中实现

- (IBAction)done:(id)sender

{

[self.delegateBDidSave:self];

}

f.在A.h中中声明B代理

@interface A : UITableViewController<BViewControllerDelegate>


g.在A.m中实现代理方法

- (void)BDidSave:(B *)controller

{

[selfdismissViewControllerAnimated:YEScompletion:nil];

}

h.在A.m中实现

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

{

   if ([segue.identifierisEqualToString:@"AddPlayer"])

{

UINavigationController *navigationController =

        segue.destinationViewController;

B

        *b =

        [[navigationControllerviewControllers]

         objectAtIndex:0];

b.delegate =self;

}

}




0 0
原创粉丝点击