ecslidingtableviewcontrollerr怎么传值

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
I am trying to implement ECSlidingViewController & I am using segues in my storyboards. I am having a problem where the MainViewController's viewDidLoad is being called twice and
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
is always getting set to null. More information.
LogIn Screen ( InitViewController ) ------through segue---------> MainViewController.
In my MainViewController I have the following code.
-(void)addMenuViewControllerWithGesture{
self.view.layer.shadowOpacity = 0.075f;
self.view.layer.shadowRadius = 10.0f;
self.view.layer.shadowColor = [UIColor blackColor].CGC
if (![self.slidingViewController.underLeftViewController isKindOfClass:[rsMenuViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
In My InitViewController (LogIn)
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
MainViewController *controller = segue.destinationViewC
// setting some values before going to the next view.
controller.id = 0;
controller.name = @"harish";
self.topViewController =
By doing this, the MainViewController's viewDidLoad is getting called twice and the below value is always set to null.
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
Hope it's clear. I am kind of stuck here and looking for a solution.
user529758
Okay, I figured it out. After a long, arduous experience, I figured it out. I asked a similar question here:
and eventually answered it. I just recently came upon your question.
So let's say you have numerous files (.m and .h for each):
InitViewController
MenuViewController
MainViewController
SpeakersView
The objective was to switch from MainViewController using a button not on the slide menu to SpeakersView, but doing it directly caused the slide menu to be null, as was pointed out by Phillip Mills.
Instead, I put this in InitViewController.h, right underneath @Interface:
@property (nonatomic, retain) NSString *
Then this under @implementation in InitViewController.m:
I originally had this under ViewDidLoad in InitViewController.m:
self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Main"];
I changed it to this:
if([location length] == 0){location = @"Main";}
self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:location];
That way if the variable was empty, it defaulted to @"Main".
Then in MainView.m, where I execute the code after pressing the button, I have this:
InitViewController *
ini = [self.storyboard instantiateViewControllerWithIdentifier:@"Init"];
ini.location = @"Speakers";
And voilà, the view switches just fine to Speakers. More accurately, it switches to InitViewController which automatically switches to Speakers or whatever I set location to.
Hopefully this helps you.
Any questions, let me know.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled您现在的位置: &
【iOS视图切换】ECSlidingViewController
【iOS视图切换】ECSlidingViewController
ECSlidingViewController 是一个视图控制器容器,将子视图处理成两层,通过滑动来进行层的切换,类似 Path 2.0 和 Facebook 的 app。 本资料共包含以下附件: ECSlidingViewController.zip
(本资料免费下载)
&&&主编推荐
&&&热门试卷
&&&最新视频
&&&热门阅读
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&&&湘教QS2-164&&增值电信业务经营许可证湘B2-论坛开源项目推荐(11月26日)
ECSlidingViewController一侧边栏目录控件
一个非常好的侧边栏目录的控件。它支持所有的屏幕尺寸,重力感应支持,storyboards支持,自定义过渡支持。动画,交互以及布局你都可以自己定制。这个例
&TCBlobDownload使用队列实现大文件下载
这个库使用NSOperations实现了大文件下载。作者最大测试了1.2G的文件,可以实现后台下载,现在仅支持ARC。
项目地址:
JCMenu展开菜单
JCMenu 点击展开菜单
项目地址:
ExtensiveCell点击Cell弹出视图
iOS TableViewCell 组件,选择单元格,然后显示一个下拉的详情信息。
项目地址:
UzysCircularProgressPullToRefresh自定义下拉刷新样式
项目地址:
ECSlidingViewController一侧边栏目录控件
一个非常好的侧边栏目录的控件。它支持所有的屏幕尺寸,重力感应支持,storyboards支持,自定义过渡支持。动画,交互以及布局你都可以自己定制。这个例子实现了折叠,放大缩小以及UIKit Dynamics的各种过渡动画。
项目地址:
RMStepsController&&用户引导iOS控件&
用户导航栏引导的iOS控件,用类似面包屑导航方式一步步引导用户。
项目地址:
TimeSquare 改进成&携程旅行&可选区间日历
一个朋友需要帮忙弄一个 类似 携程旅行那种可以选择 日期区间的日历, 朋友用的是 TimeSquare日历,理解TimeSqure怎么工作之后就努力改成了所需要的日历了,有需要的朋友可以看看,有疑问的欢迎随时讨论,改的不合理的地方请积极指出,共同进步。
原帖地址:
CLImageEditor&&图片编辑处理器
CLImageEditor提供了最基本的图片处理编辑功能。如编辑,滤镜,颜色调整,裁剪,旋转,色彩曲线功能。
项目地址:
EKAlgorithms&&算法,数据结构,Objective-C实现的开源项目
EKAlgorithms中包含了一些经典的算法,数据结构以及一些Objective-C 实现的开源项目。同时该项目还在不断更新中。
项目地址:
使用协议代理Delegate与通知中心NSNotificationCenter实现页面传值
以页面A改变页面B背景颜色为例写了简单的一个Demo!&
原帖地址:
CocoaChina是全球最大的苹果开发中文社区,官方微信每日定时推送各种精彩的研发教程资源和工具,介绍app推广营销经验,最新企业招聘和外包信息,以及Cocos2d引擎、Cocos Studio开发工具包的最新动态及培训信息。关注微信可以第一时间了解最新产品和服务动态,微信在手,天下我有!
请搜索微信号“CocoaChina”关注我们!
关注微信 每日推荐
扫一扫 浏览移动版收起评论 (0)
说点什么吧
Random Posts 随机文章
Recent Posts 最新文章
Categories 分类目录3508人阅读
ECSlidingViewController这个也是一个挺著名的托管在Github上的开源项目。目前这个项目的主要灵感还是来来源于Path2.0和Facebook在iPhone上的应用。
Github上Project的URL是:
源码的下载地址:/edgecase/ECSlidingViewController/zipball/master
OK,Facebook国内被墙,咱就下个Path用用,这个App还是蛮酷的。也是一个社交类的应用,现在社交真是泛滥,各种圈子,找朋友一窝而上,各种app都开始有圈子找朋友的需求。从QQ火爆的聊天,到现在的潜水不语,强关系的应用,有时候也不简单就一定会有很长的生命周期,有时候,距离产生美么。说了很多废话,下面先简单介绍一下ECSlidingViewController。
简而言之,ECSlidingViewController是一个iOS中一个ViewController的容器,这个将其中的子ViewController分成了二个层。二层view controller滑动,上面的不完全滑出,显示出后面的view controller。
一些feature(从github上翻译过来,可能存在不准确的地方):
1.任何一个UIView上的横向滑动的手势都能移动Top view,这个有点像navigation bar或者就是一个top view。
2.可配置的停留位置,也就是说,top view还存留在可视界面的宽度是可以定制的。当然这个,并且是可以根据你旋转情况自动调整的。
3.Top view下面的view的大小和layout应该并不是严格要求的。
4.子View可以随时灵活变化。
5.这个容器的子viewcontroller可以是UIViewController的子类,UINavigationController这样的都可以被承载在这个容器中。
当然使用这个控件也是有要求的:iOS5和ARC。
源码下载下来的是一个使用ECSlidingController的Demo程序,其实你要用这个框架就4个文件:ECSlidingViewController.h/m,UIImage+ImageWithUIView.h/m。
简单介绍一下这四个文件:
1.ECSlidingViewController这个二个文件中,最主要的就是我们上面说的那个ViewController容器类,这二个文件中,还有一个对UIViewController的Extension,名为:SlidingViewExtension,还提供了一个instance method,叫:SlidingViewExtension。
2.UIImage+ImageWithUIView.h/m这二个文件,就简单一些了,他们就是一个对于UIView的扩展,提供了一个叫:ImageWithUIView的extension,这个扩展里面有一个方法,是将UIView转化成UIImage,其实简单来说,就是提供了一个ScreenShot的方法。头文件中的函数声明为:+ (UIImage *)imageWithUIView:(UIView *)ECSlidingViewController这个类中有很多属性,但是无非都是标识,Controller容器里面Controller的ECLeft或者ECRight的层次顺序。方法也都是类似的,我们抽取其中一个函数进行一下说明:- (void)anchorTopViewTo:(ECSide)side animations:(void (^)())animations onComplete:(void (^)())complete这个函数其实就是这个框架的,滑动动画的核心函数。可以看到这个函数有三个参数,第一个标识动画移动的方向,第二个(animation)和第三个(onComplete),这个二个参数可以为空的。可能看到这个函数的参数会觉得很奇怪,可能这个语法平时用的不多,animations和complete都是一个叫做Block
Object的参数。也就是说,这个函数的位置可以填写一个函数实现,其实某种程度上有些像是C里面的函数指针。Block Object介绍的URL:下面是这个函数的全部实现:- (void)anchorTopViewTo:(ECSide)side animations:(void (^)())animations onComplete:(void (^)())complete
CGFloat newCenter = self.topView.center.x;
if (side == ECLeft) {
newCenter = self.anchorLeftTopViewC
} else if (side == ECRight) {
newCenter = self.anchorRightTopViewC
[self topViewHorizontalCenterWillChange:newCenter];
[UIView animateWithDuration:0.25f animations:^{
if (animations) {
animations();
[self updateTopViewHorizontalCenter:newCenter];
} completion:^(BOOL finished){
if (_resetStrategy & ECPanning) {
self.panGesture.enabled = YES;
self.panGesture.enabled = NO;
if (complete) {
complete();
_topViewIsOffScreen = NO;
[self addTopViewSnapshot];
dispatch_async(dispatch_get_main_queue(), ^{
NSString *key = (side == ECLeft) ? ECSlidingViewTopDidAnchorLeft : ECSlidingViewTopDidAnchorR
[[NSNotificationCenter defaultCenter] postNotificationName:key object:self userInfo:nil];
其实看这个函数好像很多的样子,其实主要就二部分:CGFloat newCenter = self.topView.center.x;
if (side == ECLeft) {
newCenter = self.anchorLeftTopViewC
} else if (side == ECRight) {
newCenter = self.anchorRightTopViewC
[self topViewHorizontalCenterWillChange:newCenter];
和一个函数调用:animateWithDuration:animations:completion第一部分的作用很简单,标识了二个图层,Center的变化。
第二个部分就是展示这个动画。
同样可以看到这个函数,+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion这个函数是UIView类里面的一个Class Method。其中animations不能为空。其实这个函数的调用就是这个框架动画的核心。
例如下面的代码:
- (IBAction)buttonpress:(id)sender
newcenter.x = 300;
newcenter.y = 100;
[UIView animateWithDuration:0.25f
animations:^{testimage.center = }
completion:NULL];
实现的效果就是点击Button后,图片进行了一个位置的移动。效果图:
OK,这个框架介绍基本就完了。
其实这个框架最帅的地方就是:动画的效果将几个UIViewController很好的联系起来,还有一个就是巧妙的用了ScreenShot的方法去提高效率和内存的使用。
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:69080次
排名:千里之外
原创:18篇
评论:19条
(1)(1)(1)(2)(1)(1)(1)(1)(1)(1)(2)(5)(1)(1)(2)

我要回帖

更多关于 pageviewcontroller 的文章

 

随机推荐