请选择 进入手机版 | 继续访问电脑版
查看: 500|回复: 0

[手机开发] UI_模态页面跳转

3万

主题

3万

帖子

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
100197
发表于 2015-7-11 14:11:04

前一页建立跳转事件

  1. <span class="hljs-comment">// 添加左边导航栏按钮</span>
  2. <span class="hljs-built_in">UIBarButtonItem</span> *leftButton = [[<span class="hljs-built_in">UIBarButtonItem</span> alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:<span class="hljs-keyword">self</span> action:<span class="hljs-keyword">@selector</span>(leftButtonAction:)];
  3. <span class="hljs-keyword">self</span><span class="hljs-variable">.navigationItem</span><span class="hljs-variable">.leftBarButtonItem</span> = leftButton;</code>
复制代码
  1. <span class="hljs-preprocessor">#pragma mark - 导航栏左边按钮实现</span>
  2. - (<span class="hljs-keyword">void</span>)leftButtonAction:(<span class="hljs-built_in">UIBarButtonItem</span> *)sender
  3. {
  4. <span class="hljs-comment">// 模拟推出页面,被推出的页面</span>
  5. AddViewController *addVC = [[AddViewController alloc] init];
  6. [<span class="hljs-keyword">self</span> presentViewController:addVC animated:<span class="hljs-literal">YES</span> completion:<span class="hljs-literal">nil</span>];
  7. }</code>
复制代码

后一页跳转回来

  1. <span class="hljs-comment">// 添加点击事件</span>
  2. [<span class="hljs-keyword">self</span><span class="hljs-variable">.rootView</span><span class="hljs-variable">.cancleButton</span> addTarget:<span class="hljs-keyword">self</span> action:<span class="hljs-keyword">@selector</span>(cancleButtonDidClickde:) forControlEvents:UIControlEventTouchUpInside];</code>
复制代码
  1. <span class="hljs-comment">// 实现点击事件</span>
  2. - (<span class="hljs-keyword">void</span>)cancleButtonDidClickde:(<span class="hljs-built_in">UIButton</span> *)sender
  3. {
  4. <span class="hljs-comment">// 跳到前一页</span>
  5. [<span class="hljs-keyword">self</span> dismissViewControllerAnimated:<span class="hljs-literal">YES</span> completion:<span class="hljs-literal">nil</span>];
  6. }</code>
复制代码

版权声明:本文为编程学堂(www.bcxue.com)转载于网络,仅供大家参考学习用。



回复

使用道具 举报