请教一个问题 英文popViewControllerAnimated的问题

popToViewController用法 - 搞不死 - ITeye技术网站
博客分类:
popToViewController用法:
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2]
animated:YES];
for (UIViewController *temp in self.navigationController.viewControllers) {
if ([temp isKindOfClass:[你要跳转到的Controller class]]) {
[self.navigationController popToViewController:temp animated:YES];
转载自:/bbs/read.php?tid=87184
浏览 11748
浏览: 136895 次
来自: 安徽
如果 日期类型里面 有
年月 和 年月日 一同存在的呢?
还真是。。别人写的都用不了,在这里找到问题所在了。。
楼主 我也遇见同样的问题
怎么解决的 ...
为什么我这边提示ABRecordCopyValue 找不到呢? ...
去哪儿面试?> 运行popToRootViewControllerAnimated 返回最上层后,dealloc运行
运行popToRootViewControllerAnimated 返回最上层后,dealloc运行
lbn306618 & &
发布时间: & &
浏览:2 & &
回复:0 & &
悬赏:0.0希赛币
代码如下:@interface&A&:&UIViewController&&UITextFieldDelegate&{&&&&UITextField&*inputN}@property&(nonatomic,retain)&UITextField&*inputN@end....m文件@implementation&A@synthesize&inputN-&(void)dealloc{&&&&if(inputName&!=&nil)&&&&{&&&&&&&&[inputName&release];&&&&&&&&inputName&=&&&&&}&&&[super&dealloc];}//A类的dealloc函数调用后报错。EXC_BAD_ACCESS(code&=&1,address=0xd000000c)pushViewController代码如下:aa&=&[[A&alloc]&init];&&&&&&&&[self.navigationController&pushViewController:aa&animated:YES];&&&&&&&&[aa&release];&&&&&&&&aa&=&popToViewController&代码如下:NSArray&*array&=&self.navigationController.viewC&&&&B&*app&=&(B&*)([array&objectAtIndex:[array&count]&-&3]);&&&&[self.navigationController&popToViewController:(UIViewController&*)app&animated:YES];&&&&//[self.navigationController&popToRootViewControllerAnimated:YES];在执行popToViewController&或popToRootViewControllerAnimated,返回最顶层后,A类的dealloc函数调用到了,然后报错。EXC_BAD_ACCESS(code&=&1,address=0xd000000c)错误在init里面&inputName&=&[[UITextField&alloc]initWithFrame:CGRectMake(10,&Img.size.height&+&Img.size.height&/&2,&Img.size.width,Img.size.height)];&&&&inputName.delegate&=&&&&&[self.view&addSubview:inputName];&&&&[inputName&release];在这个地方inputName&release有什么问题吗?如果我把[inputName&release];这条语句去掉,dealloc里面就不报错了,我跑了retainCount语句,addSubview之后retainCount是2,在&dealloc里面retainCount输出也是2,我的整个做法哪里有问题吗?
本问题标题:
本问题地址:
温馨提示:本问题已经解决,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&我的笔记本 的BLOG
用户名:我的笔记本
文章数:207
访问量:155414
注册日期:
阅读量:5863
阅读量:12276
阅读量:420546
阅读量:1108818
51CTO推荐博文
更改pushViewController和popViewController的动画效果/bbs/read.php?tid=33258iPhone SDK的NavigationController提供的动画效果默认只有一种,如何实现各种不同的呢?下面是来自three20的实现,大家只要把这两个方法作为UINavigationController的Category方法调用就可以了- (void)pushAnimationDidStop {}- (void)pushViewController: (UIViewController*)controller&&& animatedWithTransition: (UIViewAnimationTransition)transition {& [self pushViewController:controller animated:NO];& [UIView beginAnimations:nil context:nil];& [UIView setAnimationDuration:TT_FLIP_TRANSITION_DURATION];& [UIView setAnimationDelegate:self];& [UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)];& [UIView setAnimationTransition:transition forView:self.view cache:YES];& [UIView commitAnimations];}- (UIViewController*)popViewControllerAnimatedWithTransition:(UIViewAnimationTransition)transition {& UIViewController* poppedController = [self popViewControllerAnimated:NO];& [UIView beginAnimations:nil context:NULL];& [UIView setAnimationDuration:TT_FLIP_TRANSITION_DURATION];& [UIView setAnimationDelegate:self];& [UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)];& [UIView setAnimationTransition:transition forView:self.view cache:NO];& [UIView commitAnimations];& return poppedC}
了这篇文章
类别:未分类┆阅读(0)┆评论(0)最近在项目中,遇到一个问题:&
实现类似于设置功能的简单应用,方法是中在storyboard中,基于UITableView 建立一个静态tableViewCell。基于这个静态cell直接在storyboard上拖拽到下一级Controller, 方法为push。
问题现象:ios8以上系统没有问题。到ios7系统,出现crash. 最后用下边博文的方法解决。
转载分享给大家,下面是转载原文 :
---------------------------------
iOS7 相比iOS8及以后,在页面进入或者退出的时候,有一定延迟
比如push到子页面的时候,如果viewwillappear 还没有完成,就直接再进入下一个页面,就会crash
举例场景:用户查看自己的地址列表时,如果地址列表为空,产品希望我们APP自动跳转到新建地址的页面
这个常规的做法是在viewdidload里面request address list,在response里面,判断如果空的话,push到新建address的页面
做出来,iOS8.9都ok,但是在iOS7上就会直接crash
类似很多场景(push/pop操作未完成,就继续push/pop),如果大家crash,能看到“Can't add self as subview”
类似这种,就是其中之一的场景。
这种的主流解决方案是:在viewwillappear的时候再执行相关动作。
我这边自己用过的一个方式是使用了个开源库:
插一段代码,其实就是建了个父类在所有pop或者push的接口做了统一处理
A-&B, Apush 到B,但实际页面还是A,但是导航左上角是个返回按钮(push后自带的返回上一页的backButton),然后整个页面点击无任何响应.
使用了tabbrviewcontroller, 有4个tab(tabA,tabB .... tabD)
然后从2个tab,进入了子页面N多层,最后来到页面M,然后点击M页面的提交button后,希望回到第2个界面B。&
需要达到的效果是,也可能从任何一个tab进入页面M,但都需要进入界面B
实现方式:
[self.navigationController popToRootViewControllerAnimated:NO];
然后发个通知,让tabbarViewController设置select为tabB,然后pushViewController到界面B
解决方案:
可能很多童鞋都没看懂,我说了什么,总结下就是popToRootViewController之后,在rooview还没出现viewappear的时候,执行pushViewController,操作,iOS7会出现页面错乱
但是这个又和上一个问题不太一样,因为之前已经使用了SafeTransition,不应该出这种问题的。
后来想了下,这个是appdelegate接受Notification 的,而Notification无法保证在主线程(理论上来说,Notification是线程安全的,同时post 和receive是在一个线程里面,但是在这里出了错误,说明的确有问题),于是在pushviewcontroller的地方增加为主线程,于是问题解决。
备注:这个没有更新完,待补充,具体我需要查看下实际所在的线程,确认在iOS7上的情况,但目前的解决方案是如此。谨记之
dispatch_async(dispatch_get_main_queue(), ^{
[currentViewController PushViewController:viewController animation:animation];
文/pingpong_龘(简书作者)
原文链接:/p/b49a87093ac4
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
直接将这个分类的源文件,加入项目即可,利用了runtime机制将一部分生命周期函数替换成安全的方式。
UINavigationController+APSafeTransition.h
Created by hanamichi on 16/1/4.
Copyright © 2016年 hanamichi. All rights reserved.
#import &UIKit/UIKit.h&
#import &objc/runtime.h&
@interface UINavigationController () &UINavigationControllerDelegate&
@property (nonatomic, assign) BOOL viewTransitionInP
@implementation UINavigationController (APSafeTransition)
+ (void)load {
method_exchangeImplementations(class_getInstanceMethod(self, @selector(pushViewController:animated:)),
class_getInstanceMethod(self, @selector(safePushViewController:animated:)));
method_exchangeImplementations(class_getInstanceMethod(self, @selector(popViewControllerAnimated:)),
class_getInstanceMethod(self, @selector(safePopViewControllerAnimated:)));
method_exchangeImplementations(class_getInstanceMethod(self, @selector(popToRootViewControllerAnimated:)),
class_getInstanceMethod(self, @selector(safePopToRootViewControllerAnimated:)));
method_exchangeImplementations(class_getInstanceMethod(self, @selector(popToViewController:animated:)),
class_getInstanceMethod(self, @selector(safePopToViewController:animated:)));
#pragma mark - setter & getter
- (void)setViewTransitionInProgress:(BOOL)property {
NSNumber *number = [NSNumber numberWithBool:property];
objc_setAssociatedObject(self, @selector(viewTransitionInProgress), number, OBJC_ASSOCIATION_RETAIN);
- (BOOL)viewTransitionInProgress {
NSNumber *number = objc_getAssociatedObject(self, @selector(viewTransitionInProgress));
return [number boolValue];
#pragma mark - Intercept Pop, Push, PopToRootVC
- (NSArray *)safePopToRootViewControllerAnimated:(BOOL)animated {
if (self.viewTransitionInProgress)
if (animated) {
self.viewTransitionInProgress = YES;
NSArray *viewControllers = [self safePopToRootViewControllerAnimated:animated];
if (viewControllers.count == 0) {
self.viewTransitionInProgress = NO;
return viewC
- (NSArray *)safePopToViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (self.viewTransitionInProgress)
if (animated){
self.viewTransitionInProgress = YES;
NSArray *viewControllers = [self safePopToViewController:viewController animated:animated];
if (viewControllers.count == 0) {
self.viewTransitionInProgress = NO;
return viewC
- (UIViewController *)safePopViewControllerAnimated:(BOOL)animated {
if (self.viewTransitionInProgress)
if (animated) {
self.viewTransitionInProgress = YES;
UIViewController *viewController = [self safePopViewControllerAnimated:animated];
if (viewController == nil) {
self.viewTransitionInProgress = NO;
return viewC
- (void)safePushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (self.viewTransitionInProgress == NO) {
[self safePushViewController:viewController animated:animated];
if (animated) {
self.viewTransitionInProgress = YES;
@implementation UIViewController (APSafeTransitionLock)
+ (void)load {
Method m1;
Method m2;
m1 = class_getInstanceMethod(self, @selector(sofaViewDidAppear:));
m2 = class_getInstanceMethod(self, @selector(viewDidAppear:));
method_exchangeImplementations(m1, m2);
- (void)sofaViewDidAppear:(BOOL)animated {
self.navigationController.viewTransitionInProgress = NO;
[self sofaViewDidAppear:animated];
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:969299次
积分:6521
积分:6521
排名:第3287名
原创:63篇
转载:259篇
评论:128条
Github& -&
Email &&-&
(3)(2)(2)(11)(1)(20)(17)(3)(3)(7)(8)(3)(9)(17)(3)(1)(1)(10)(4)(2)(30)(122)(32)(3)(5)(3)(4)问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
我的代码如下:
我是这样跳到登陆页的:
LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:Nil bundle:nil];
UINavigationController *myNavigationController = [[UINavigationController alloc] initWithRootViewController:loginVC];
[self presentViewController:myNavigationController animated:YES completion:nil];
然后登陆页后退的时候。返回到tab。主页。
[self dismissViewControllerAnimated:NO completion:^{
[self.navigationController pushViewController:[[RankViewController alloc] init] animated:NO];
[self.tabBarController setSelectedIndex:0];
我的意思就是直接返回tab首页。不要带任何导航控制器。因为带的话。导航栏就会有后退按钮。
彻底搞混了。求指教呀
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
你登录页在什么时候跳的,如果在首页 直接[self dismissViewControllerAnimated:no]就可以了
同步到新浪微博
分享到微博?
Hi,欢迎来到 SegmentFault 技术社区!⊙▽⊙ 在这里,你可以提出编程相关的疑惑,关注感兴趣的问题,对认可的回答投赞同票;大家会帮你解决编程的问题,和你探讨技术更新,为你的回答投上赞同票。
明天提醒我
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
扫扫下载 App}

我要回帖

更多关于 请教一个问题 英文 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信