rickytan / rtrootnavigationcontroller Goto Github PK
View Code? Open in Web Editor NEWImplicitly make every view controller has its own navigation bar
License: MIT License
Implicitly make every view controller has its own navigation bar
License: MIT License
如何pop到指定页面,
A - push -B
B - Push -C
C- Push - D
D 物理按钮怎么pop到A
D 返回按钮还需要支持pop到C
博主,你的返回按钮和滑动返回的时候如何进行判断是否模态视图进入呢?
请问,需要关闭或开启单独一个控制器的全屏返回手势,要设置什么属性
我的使用方法是这样的:在storyboard中把几个自定义tabbarController添加的NavigationController都改成
RTRootNavigationController,启动运行后各个页面都能右滑了。但是后来发现重新启动后主页面的viewDidAppear没执行到,而我的数据请求是放在viewDidAppear中载入的。
另外我的主页面是通过第三方框架VTMagic来切换加载的,这是一个导航菜单框架。我猜想的是RTRootNavigationController对UIViewController的扩展和VTMagic对UIViewController的扩展冲突了,导致VTMagic的生命周期方法执行失效。看了半天也没看出具体哪出问题了,所以想请教兄弟看一下到底哪出错了。谢谢!
您好,请问您对这个presentViewController 有什么解决方案么?
请问,需要关闭或开启单独一个控制器的全屏返回手势需要设置什么属性?
层级结构
RTRootNavigationController->UITabBarController -->RTRootNavigationController---》VC1
-->RTRootNavigationController---》VC2
-->RTRootNavigationController---》VC3
说明:
第一级RTRootNavigationController
是为了方便Routable
来弹出其他ViewController
,因此需要隐藏
第二级UITabBarController
分成三个页面,每一个页面对应自己一个RTRootNavigationController
。
需求:
RTRootNavigationController
隐藏(首页隐藏NavigationBar)。代码:
在AppDelegate
:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
TabBarController *tabbarController = [[TabBarController alloc] init];
RTRootNavigationController *nav = [[RTRootNavigationController alloc] initWithRootViewController:tabbarController];
[nav setNavigationBarHidden:YES];
self.window.rootViewController = nav;
因为要做一个类似天猫商品类别筛选的悬浮VIEW在bar的下面,随着table的滑动这个view悬浮在屏幕顶端,找到了TLYShyNavBar这个第三方,会出现bar减少20像素的问题。
使用 initWithRootViewController 不会调用 rt_navigationBarClass,无法直接自定义navigationBarClass
RTRootNavigationController针对各别页面怎样右滑返回顶层VC,而不是返回上一级VC?
我自定义了一个UIScrollView用于图片查看模式,可以左右滚动查看图片。
在这个VC中RTRootNavigationController的右滑无法响应,然后我使用两种方法设置代理来解决都没用,这个问题该怎么解?
方法一:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
// 首先判断otherGestureRecognizer是不是系统pop手势
if ([otherGestureRecognizer.view isKindOfClass:NSClassFromString(@"UILayoutContainerView")]) {
// 再判断系统手势的state是began还是fail,同时判断scrollView的位置是不是正好在最左边
if (otherGestureRecognizer.state == UIGestureRecognizerStateBegan && self.contentOffset.x == 0) {
return YES;
}
}
return YES;
}
方法二:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([otherGestureRecognizer isKindOfClass:[UIScreenEdgePanGestureRecognizer class]]) {
[gestureRecognizer requireGestureRecognizerToFail:otherGestureRecognizer];
return NO;
}
return YES;
}
RT,希望楼主指点一下
UIToolbar 显示和影藏出现位置偏差
全屏侧滑返回,或者距离左侧一定距离才触发,请问这个怎么做?
self.rt_navigationController.viewControllers.count 只能这样写才能正确的获得控制器数组。
没有办法么?项目已经是成型的,想加一下这个导航栏效果。
工程中使用RTRootNavigationController后,在controller中重写 - (BOOL)canBecomeFirstResponder ,导致不能调用canBecomeFirstResponder;
博主,想问一下如何才能调用全屏返回功能呢?
self.navigationController.navigationBar.barStyle = UIBarStyleDefault; 不起作用了,在系统的navgationcoller下设置是起作用的,但是在RTRootNavigationController下的viewcontroller中设置不起作用。只能通过preferredStatusBarStyle 改变状态栏颜色。不知道是不是bug?
我自定义了一个UIScrollView用于图片查看模式,可以左右滚动查看图片。
在这个VC中RTRootNavigationController的右滑无法响应,然后我使用两种方法设置代理来解决都没用,这个问题该怎么解?
方法一:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
// 首先判断otherGestureRecognizer是不是系统pop手势
if ([otherGestureRecognizer.view isKindOfClass:NSClassFromString(@"UILayoutContainerView")]) {
// 再判断系统手势的state是began还是fail,同时判断scrollView的位置是不是正好在最左边
if (otherGestureRecognizer.state == UIGestureRecognizerStateBegan && self.contentOffset.x == 0) {
return YES;
}
}
return YES;
}
方法二:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
我原先是tabbar加载的,storyboard指定了一个RTRootNavigationController,然后它的viewcontroller是现在要打开的页面,这样是没问题的。但是现在页面结构变了,要在主页面中单独打开这个页面,也就没有RTRootNavigationController这一层了,那要怎样让这个单个页面支持右滑?
下载你的Demo,注释掉appdelegate的代码,使用包含tabbarController的例子,然后发现Root那个tabbar的根控制器是RTStaticTableViewController,我想要修改这个控制器的导航栏背景色,或者自定义导航栏样式,在该.m文件中添加rt_navigationBarClass这个方法,返回一个自定义UINavigationBar类,但是没有效果,请问,在这种情况下,如何修改根控制器的导航栏背景?
也是使用tabbarController的例子,在根控制器的.m文件里修改statusbar的样式,没有效果,然后push到一个新的控制器进来,就可以修改了
RTAppDelegate
持续关注此库,在正式项目中试用
pop后contentViewController的didMoveToParentViewController方法不会调用
是不是应该重写一下RTContainerController的didMoveToParentViewController方法
你好,在项目中原先使用了Aspects库替换了UIViewController的viewDidAppear 、viewDidDisappear方法,现在集成了这个库后不能正常的使用,导航栏不能正常的显示,会打印 Unbalanced calls to begin/end appearance transitions for <RTContainerController: 0x7f91b2428400>. 错误信息,有什么解决方法吗?
附件是Demo~
RTNaviDemo.zip
我在demo的RTWebViewController界面中,添加了一个按钮,事件是每次点击,当前controller的rt_disableInteractivePop置非,
即:self.rt_disableInteractivePop = !self.rt_disableInteractivePop
在执行这个方法前能划出屏幕的情况下,执行之后,依旧能够划出屏幕(正常应该不能再划出了);
反之亦然;
真实的使用场景例如在 WKWebview 中,设置webview 的allowsBackForwardNavigationGestures 为yes,如果 webivew 的 canGoBack 的值是 YES,此时就不应该触发滑动退出页面的事件,而应该触发webview的goBack事件(类似微信的webview)
根据我的观察,存在以下几种情况
1.在viewDidLoad方法中设置 rt_disableInteractivePop 的值会生效;
2.WKWebview有缓存后,根据webview的状态(是否能goBack)在主线程重新设置rt_disableInteractivePop的值会生效;
我的项目结构是:根视图是RDVTabBarController(算是一种自定义tabbarcontroller),他的ViewControllers是RTRootNavigationController,当push到一个隐藏了底部tabbar的ViewController里时,底部就会留出来空白,当我慢慢的侧滑返回又取消时,就会填充满。
图片传不上来,我整理了demo:https://github.com/songhailiang/RTNavigationDemo
请帮我看一下,应该怎么处理,万分感谢。
如题
错误信息如下:
2016-08-29 10:47:52.136 RTRootNavigationController_Example[53635:10524179] *** Assertion failure in -[UIAlertController supportedInterfaceOrientations], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UIAlertController.m:542
2016-08-29 10:47:52.141 RTRootNavigationController_Example[53635:10524179] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIAlertController:supportedInterfaceOrientations was invoked recursively!'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a1aad85 exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000109c1edeb objc_exception_throw + 48
2 CoreFoundation 0x000000010a1aabea +[NSException raise:format:arguments:] + 106
3 Foundation 0x0000000107c03d5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 UIKit 0x0000000108302313 -[UIAlertController supportedInterfaceOrientations] + 316
5 RTRootNavigationController_Example 0x0000000107a9c7f6 -[RTRootNavigationController supportedInterfaceOrientations] + 70
6 UIKit 0x0000000108302258 -[UIAlertController supportedInterfaceOrientations] + 129
7 UIKit 0x0000000108193d6c -[UIViewController __supportedInterfaceOrientations] + 701
8 UIKit 0x00000001081943c5 -[UIViewController __withSupportedInterfaceOrientation:apply:] + 45
9 UIKit 0x0000000108194c59 -[UIViewController setInterfaceOrientation:] + 145
10 UIKit 0x000000010817d9a3 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 1458
11 UIKit 0x000000010808f58c -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1609
12 UIKit 0x0000000108084562 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 155
13 Foundation 0x0000000107b8d3d3 -[NSISEngine withBehaviors:performModifications:] + 155
14 UIKit 0x0000000108084480 -[UIView(Hierarchy) _postMovedFromSuperview:] + 575
15 UIKit 0x000000010809226c -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1967
16 UIKit 0x00000001082ebd63 -[_UIAlertControllerPresentationController presentationTransitionWillBegin] + 208
17 UIKit 0x000000010814af44 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 2035
18 UIKit 0x0000000108148b76 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 309
19 UIKit 0x0000000107fe6f62 _runAfterCACommitDeferredBlocks + 317
20 UIKit 0x0000000107ffae4c _cleanUpAfterCAFlushAndRunDeferredBlocks + 95
21 UIKit 0x0000000108007147 _afterCACommitHandler + 90
22 CoreFoundation 0x000000010a0cfc37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
23 CoreFoundation 0x000000010a0cfba7 __CFRunLoopDoObservers + 391
24 CoreFoundation 0x000000010a0c57fb __CFRunLoopRun + 1147
25 CoreFoundation 0x000000010a0c50f8 CFRunLoopRunSpecific + 488
26 GraphicsServices 0x000000010c48dad2 GSEventRunModal + 161
27 UIKit 0x0000000107fdaf09 UIApplicationMain + 171
28 RTRootNavigationController_Example 0x0000000107a9527f main + 111
29 libdyld.dylib 0x000000010b3e792d start + 1
30 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
主要是没有UIScrollView(UITableView)等滚动视图做根视图的情况下发生
使用了该库之后,
self.navigationController.viewControllers 得到的数组,只有一个数据;
请问,可以通过什么方式,拿到正常的viewcontroller数组呢
我在AppDelegate里使用UINavigationbar appearance无法修改导航栏的样式:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:58/255.0 green:58/255.0 blue:58/255.0 alpha:1.0]]; [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor],NSForegroundColorAttributeName ,[UIFont systemFontOfSize:20.0], NSFontAttributeName, nil]];
没有任何效果
@rickytan 你好,我在原来的代码中使用到self.navigationController.viewControllers;直接使用您的这个项目好像会出问题,self.navigationController.viewControllers;返回的数组中正常情况下只会包含当前的vc,是不是需要重写一下viewControllers的getter方法,谢谢回答!
主要是考虑了哪些方面的因素呢?
还望能指点一下,感谢!
在swift 3 中 ,在VC的viewDidLoad下调用,不管是
self.navigationController
还是
self.rt_navigationController
都会中断在
- (void)setViewControllers:(NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated
{
if (self.navigationController)
[self.navigationController setViewControllers:viewControllers
animated:animated];
else
[super setViewControllers:viewControllers animated:animated];
}
中的倒数第二行,不知道怎么在swift 3 下对VC的navigationBar进行自定义.
还有新建一个类继承RTRootNavigationController和UINavigationControllerDelegate的时候,意在自动以过场动画,也会有如上的中断.
tabController.viewControllers = @[[[RTContainerNavigationController alloc] initWithRootViewController:vc1],
[[RTContainerNavigationController alloc] initWithRootViewController:vc2],
[[RTContainerNavigationController alloc] initWithRootViewController:vc3],
[[RTContainerNavigationController alloc] initWithRootViewController:vc4]];
self.window.rootViewController = [[RTRootNavigationController alloc] initWithRootViewControllerNoWrapping:tabController];
我想在某个页面禁止pop右滑退出,设置self.rt_disableInteractivePop = YES;但是不起作用,还是可以右滑,这是什么原因?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.