Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >iOS 7只在某些时候使用自定义交互转换。

iOS 7只在某些时候使用自定义交互转换。
EN

Stack Overflow用户
提问于 2013-11-20 22:07:33
回答 5查看 10.8K关注 0票数 14

所以我有一个UINavigationController,控制器A作为根控制器。

当我想将Controller推到顶部时,我希望使用自定义动画转换和自定义交互转换。这个很好用。

当我想将Controller推到顶部时,我想回到默认的 push/pop转换,即UINavigationController附带的转换。为了实现这一目标,我返回零

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
navigationController:animationControllerForOperation:fromViewController:toViewController:

然而,如果你返回零,那么

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
navigationController:interactionControllerForAnimationController:

永远不会被调用,默认的“从左边边缘开始”的弹出交互转换不起作用。

是否有方法返回默认的push/pop动画控制器和交互控制器?(是否有id<UIViewControllerAnimatedTransitioning>id<UIViewControllerInteractiveTransitioning>的具体实现?)

还是其他方式?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2014-01-04 08:22:36

应该将NavigationController的interactivePopGestureRecognizer委托设置为self,然后在-gestureRecognizerShouldBegin中处理其行为:

也就是说,当您希望内置的pop手势启动时,您必须从此方法返回YES。这同样适用于您的自定义手势--您必须弄清楚您正在处理的是哪个识别器。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
- (void)setup
{
    self.interactiveGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleTransitionGesture:)];
    self.interactiveGestureRecognizer.delegate = self;
    [self.navigationController.view addGestureRecognizer:self.interactiveGestureRecognizer];

    self.navigationController.interactivePopGestureRecognizer.delegate = self;
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    // Don't handle gestures if navigation controller is still animating a transition
    if ([self.navigationController.transitionCoordinator isAnimated])
        return NO;

    if (self.navigationController.viewControllers.count < 2)
        return NO;

    UIViewController *fromVC = self.navigationController.viewControllers[self.navigationController.viewControllers.count-1];
    UIViewController *toVC = self.navigationController.viewControllers[self.navigationController.viewControllers.count-2];

    if ([fromVC isKindOfClass:[ViewControllerB class]] && [toVC isKindOfClass:[ViewControllerA class]])
    {
        if (gestureRecognizer == self.interactiveGestureRecognizer)
            return YES;
    }
    else if (gestureRecognizer == self.navigationController.interactivePopGestureRecognizer)
    {
        return YES;
    }

    return NO;
}

您可以查看您的场景的样本工程。视图控制器A和B之间的转换是自定义动画,自定义B->A弹出手势。视图控制器B和C之间的转换是默认的,内置导航控制器的pop手势。

希望这能有所帮助!

票数 19
EN

Stack Overflow用户

发布于 2014-01-13 19:03:04

在出现之前,每次都需要设置委托--例如,在prepareForSeque中。如果您想要自定义转换,请将其设置为self。如果您想要默认的转换(如默认的pop转换),则将其设置为零。

票数 15
EN

Stack Overflow用户

发布于 2015-04-02 03:40:58

在每个转换之前/之后设置委托是一个有效的解决办法,但如果您实现了其他UINavigationControllerDelegate的方法,并且需要保留它们,您可以按照Ziconic的建议拥有2个委托对象,也可以使用NSObject的respondsToSelector:。在导航委托中,您可以实现:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
- (BOOL)respondsToSelector:(SEL)aSelector
{
    if (aSelector == @selector(navigationController:animationControllerForOperation:fromViewController:toViewController:) ||
        aSelector == @selector(navigationController:interactionControllerForAnimationController:)) {

        return self.interactivePushTransitionEnabled;
    }

    return [super respondsToSelector:aSelector];
}

然后,您应该确保根据需要更新interactivePushTransitionEnabled。在您的示例中,只有在显示控制器A时,才应该将属性设置为YES

还有一件事要做:强制UINavigationController重新评估其委托实现的方法。这样做是很容易做到的:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
navigationController.delegate = nil;
navigationController.delegate = self; // or whatever object you use as the delegate
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20113701

复制
相关文章
如何从Serilog请求日志记录中排除健康检查终结点
这是在ASP.NET Core 3.X中使用Serilog.AspNetCore系列文章的第四篇文章:。
依乐祝
2020/02/17
1.4K0
在.Net Core中记录日志
一个完善的系统,必然会有非常完善的日志记录,用户的操作、系统的运行状况等信息被完整的记录下来,方便我们对系统进行维护和改进。.net core 也为日志记录提供了内置的支持。
拓荒者IT
2019/09/23
1.3K0
yii2自定义日志
1.新增公共配置文件(common/config/main-local.php) 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targ
botkenni
2022/01/10
2780
记录日志
日志级别:debug<info<warn<error application.yml配置日志 logging: file: target/app.log level: ROOT: WARN cn.devmar: TRACE import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class SampleClass{ private static
华创信息技术
2019/11/08
7730
日志记录
访问应用服务器的请求都需要拥有一定权限,如果说每访问一个服务都需要验证一次权限,这个对效率是很大的影响。可以把权限认证放到 API 网关来进行。目前比较常见的做法是,用户通过登录服务获取 Token,把它存放到客户端,在每次请求的时候把这个 Token 放入请求头,一起发送给服务器。API 网关要做的事情就是解析这个 Token,知道访问者是谁(鉴定),他能做什么/访问什么(权限)。说白了就是看访问者能够访问哪些 URL,这里根据权限/角色定义一个访问列表。如果要实现多个系统的 OSS(Single Sign On 单点登录),API 网关需要和 CAS(Central Authentication Service 中心鉴权服务)做连接,来确定请求者的身份和权限。
用户1880875
2021/09/07
1.2K0
Django 中如何优雅的记录日志
日志是个好东西,但却并不是所有人都愿意记,直到出了问题才追悔莫及,长叹一声,当初要是记日志就好了。
AlwaysBeta
2020/11/11
1.9K0
Logback排除指定包/类/方法日志输出
Logback排除指定包或者类或者方法的日志输出 在logback-spring.xml中添加如下代码,可以一直点下去 <!--包--> <logger name="com.newbie.dao" level="OFF"></logger> <!--类--> <logger name="com.newbie.dao.NbDdiMonitorDao" level="OFF"></logger> <!--方法--> <logger name="com.newbie.dao.NbDdiMonitorDao.upd
4xx.me
2022/06/10
4.6K0
将Error异常日志从普通日志中剥离
  开发过程中经常需要调试和线上环境查看异常日志的需求,但普通消息与异常消息混在一起实在是非常难得找,上则NM的文档够你头痛,所以就将Error级别的日志抽离出来。   本示例采用log4net来配置:   1、先配置web.config,添加: <configSections> <!-- 添加log4net配置节 --> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4n
欢醉
2018/01/22
7500
将Error异常日志从普通日志中剥离
AWK中的字段,记录和变量【Programming】
本文为awk入门系列的第二篇文章,在本篇文章中,你可以了解到有关字段,记录和一些功能强大的awk变量。
Potato
2019/11/09
2.1K0
AWK中的字段,记录和变量【Programming】
Python 中更优雅的日志记录方案
在 Python 中,一般情况下我们可能直接用自带的 logging 模块来记录日志,包括我之前的时候也是一样。在使用时我们需要配置一些 Handler、Formatter 来进行一些处理,比如把日志输出到不同的位置,或者设置一个不同的输出格式,或者设置日志分块和备份。但其实个人感觉 logging 用起来其实并不是那么好用,其实主要还是配置较为繁琐。
崔庆才
2019/10/15
2K0
Python 中更优雅的日志记录方案
MongoDB日志记录
为了在发生故障时提供持久性,MongoDB使用预写日志记录到磁盘journal文件中。
MongoDB中文社区
2020/11/11
2.8K0
MongoDB日志记录
mysql日志记录
log-bin = /path/mysql-bin #其记录日志文件名为mysql-bin.index,mysql-bin.000001(注:重启或者单个文件超出限制会+1)
93年的老男孩
2019/12/18
4.7K0
查询listener的日志排除不能登录的错误
显然是Oracle的服务名设置错误,orcl的服务名是Oracle数据库最常用的服务名,难道会错?仔细看看listener的状态:
姚远OracleACE
2023/04/06
6270
查询listener的日志排除不能登录的错误
python 日志记录
#!/bin/env python #--*-- coding=utf8 --*-- # # Author: ablozhou # E-mail: ablozhou@gmail.com # # Copyright 2010 ablozhou # # Distributed under the terms of the GPL (GNU Public License) # # hzdq is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # 2010.3.14 写文件,log级别常数定义 import datetime import sys import traceback import codecs import types #log编码全部按utf8处理 loglevels = {'stdout':['info','debug','warn','error','fatal'], 'file':['info','debug','warn','error','fatal'] } logfile = 'logs.txt' class log4py: def __init__(self,modulename='gloabal', loglevel=loglevels, filename='log4py.txt'): self.filename = filename #self.flag = set(loglevel['stdout']+loglevel['file']) self.loglevel = loglevel self.modulename = modulename self.fcname = None class function(): def __init__(self,fcname,parent): parent.debug('enter ',fcname) self.fcname = fcname self.parent = parent def __del__(self): self.parent.debug('exit ',self.fcname) def dbgfc(self,fcname): '''set debug function name''' f = None if 'debug' in self.flag: f = self.function(fcname,self) return f def _gettime(self): return datetime.datetime.now().isoformat() def outstd(self,*fmt): s = self.fmtstr(*fmt) print s def outfile
py3study
2020/01/03
9030
[CodeIgniter4]-记录日志信息
你可以通过 log_message() 方法将信息记录在本地日志文件中,并且必须在第一个参数中指定错误的”级别”,来表明这个信息的类型(debug,error等)。 第二个参数就是信息本身:
landv
2020/03/05
1.3K0
yii2中LinkPager增加总页数和总记录数的实例
本文介绍了php中LinkPager增加总页数和总记录数,分享给大家,也给自己留个笔记
用户2323866
2021/07/02
8970
如何在Python中实现高效的日志记录
日志记录是软件开发中的重要组成部分,它可以帮助我们监控程序运行状态、诊断问题和优化性能。本文将详细介绍如何在Python中实现高效的日志记录,并提供详细的代码示例。
华科云商小彭
2023/08/29
4180
如何在Python中实现高效的日志记录
如何在Python 中更优雅的记录日志?
在 Python 中,一般情况下我们可能直接用自带的 logging 模块来记录日志,包括我之前的时候也是一样。在使用时我们需要配置一些 Handler、Formatter 来进行一些处理,比如把日志输出到不同的位置,或者设置一个不同的输出格式,或者设置日志分块和备份。但其实个人感觉 logging 用起来其实并不是那么好用,其实主要还是配置较为繁琐。
Python数据科学
2019/10/15
1.1K0
如何在Python 中更优雅的记录日志?
Apache日志变量详解
Apache日志格式字符串的含义 %% 百分号(Apache2.0.44或更高的版本) %a 远端IP地址 %A 本机IP地址 %B 除HTTP头以外传送的字节数 %b 以CLF格式显示的除HTTP头以外传送的字节数,也就是当没有字节传送时显示’-‘而不是0。 %{Foobar}C 在请求中传送给服务端的cookieFoobar的内容。 %D 服务器处理本请求所用时间,以微为单位。 %{FOOBAR}e 环境变量FOOBAR的值 %f 文件名 %h 远端主机 %H 请求使用的协议 %{Foobar}i 发送
院长技术
2020/08/24
4710
点击加载更多

相似问题

排除日志记录

21

从函数中排除日志记录

10

如何从POJO中排除某些变量以进行日志记录

112

yii2:如何从日志中排除DbTarget信息?

15

Yii2高级日志记录

11
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文