在我的应用程序中,我有一个连接到另一个 viewController(根 Controller )的导航 Controller 。在我的项目中,我导入了 ECSlidingViewController.h 和 .m。在将用作右侧菜单的 viewController (listViewController.h) 中,我导入了 ECSlidingViewController.h,在 viewDidLoad 中我这样做了:
[super viewDidLoad];
self.peekLeftAmount = 40.0f;
[self.slidingViewController setAnchorLeftPeekAmount:self.peekLeftAmount];
self.slidingViewController.underRightWidthLayout = ECVariableRevealWidth;
在 navigationController 类中,我这样做了(在导入 ECSlidingViewController.h 和 listViewController.h 之后):
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (![self.slidingViewController.underRightViewController isKindOfClass:[ListViewController class]]) {
self.slidingViewController.underRightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ListStore"];
}
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
}
但是当我运行该应用程序时,当我到达代码行 [self.view addGestureRecognizer:self.slidingViewController.panGesture]; 时,该应用程序崩溃了,并出现以下错误:
2013-09-28 01:59:55.629 Myapp[2627:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x024595e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01a6f8b6 objc_exception_throw + 44
2 CoreFoundation 0x0240bc3c -[__NSArrayM insertObject:atIndex:] + 844
3 CoreFoundation 0x0240b8e0 -[__NSArrayM addObject:] + 64
4 UIKit 0x0063f497 -[UIView(UIViewGestures) addGestureRecognizer:] + 208
5 Myapp 0x0001a934 -[MainNavigationController viewWillAppear:] + 564
6 UIKit 0x006ec28a -[UIViewController _setViewAppearState:isAnimating:] + 419
7 UIKit 0x006ec798 -[UIViewController __viewWillAppear:] + 114
8 UIKit 0x006fd310 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 199
9 UIKit 0x0097d627 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 6236
10 UIKit 0x006f478c -[UIViewController presentViewController:withTransition:completion:] + 6433
11 UIKit 0x006f4caf -[UIViewController presentViewController:animated:completion:] + 130
12 Myapp 0x00017447 -[SplashScreenViewController viewDidAppear:] + 839
13 UIKit 0x006ec2d8 -[UIViewController _setViewAppearState:isAnimating:] + 497
14 UIKit 0x006ec867 -[UIViewController __viewDidAppear:] + 146
15 UIKit 0x006ee22f __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44
16 UIKit 0x006ecbfa -[UIViewController _executeAfterAppearanceBlock] + 63
17 UIKit 0x005f1d59 ___afterCACommitHandler_block_invoke_2 + 33
18 UIKit 0x005f1cde _applyBlockToCFArrayCopiedToStack + 403
19 UIKit 0x005f1b2e _afterCACommitHandler + 568
20 CoreFoundation 0x0242153e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
21 CoreFoundation 0x0242148f __CFRunLoopDoObservers + 399
22 CoreFoundation 0x023ff3b4 __CFRunLoopRun + 1076
23 CoreFoundation 0x023feb33 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x023fe94b CFRunLoopRunInMode + 123
25 GraphicsServices 0x032da9d7 GSEventRunModal + 192
26 GraphicsServices 0x032da7fe GSEventRun + 104
27 UIKit 0x005d594b UIApplicationMain + 1225
28 Myapp 0x00002b2b main + 235
29 libdyld.dylib 0x01f54725 start + 0
30 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
请帮帮我!
最佳答案
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UIViewController *MainView = [storyBoard instantiateViewControllerWithIdentifier:@"MyMailBox"];
self.slidingViewController.topViewController = MainView;
关于iphone - viewWillAppear 时 ECSlidingViewController 错误(对象不能为 nil),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19062032/
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
在控制台中反复尝试之后,我想到了这种方法,可以按发生日期对类似activerecord的(Mongoid)对象进行分组。我不确定这是完成此任务的最佳方法,但它确实有效。有没有人有更好的建议,或者这是一个很好的方法?#eventsisanarrayofactiverecord-likeobjectsthatincludeatimeattributeevents.map{|event|#converteventsarrayintoanarrayofhasheswiththedayofthemonthandtheevent{:number=>event.time.day,:event=>ev
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss
好的,所以我的目标是轻松地将一些数据保存到磁盘以备后用。您如何简单地写入然后读取一个对象?所以如果我有一个简单的类classCattr_accessor:a,:bdefinitialize(a,b)@a,@b=a,bendend所以如果我从中非常快地制作一个objobj=C.new("foo","bar")#justgaveitsomerandomvalues然后我可以把它变成一个kindaidstring=obj.to_s#whichreturns""我终于可以将此字符串打印到文件或其他内容中。我的问题是,我该如何再次将这个id变回一个对象?我知道我可以自己挑选信息并制作一个接受该信
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
我在Rails工作并有以下类(class):classPlayer当我运行时bundleexecrailsconsole然后尝试:a=Player.new("me",5.0,"UCLA")我回来了:=>#我不知道为什么Player对象不会在这里初始化。关于可能导致此问题的操作/解释的任何建议?谢谢,马里奥格 最佳答案 havenoideawhythePlayerobjectwouldn'tbeinitializedhere它没有初始化很简单,因为你还没有初始化它!您已经覆盖了ActiveRecord::Base初始化方法,但您没有调
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我有一个服务模型/表及其注册表。在表单中,我几乎拥有服务的所有字段,但我想在验证服务对象之前自动设置其中一些值。示例:--服务Controller#创建Action:defcreate@service=Service.new@service_form=ServiceFormObject.new(@service)@service_form.validate(params[:service_form_object])and@service_form.saverespond_with(@service_form,location:admin_services_path)end在验证@ser
似乎无法为此找到有效的答案。我正在阅读Rails教程的第10章第10.1.2节,但似乎无法使邮件程序预览正常工作。我发现处理错误的所有答案都与教程的不同部分相关,我假设我犯的错误正盯着我的脸。我已经完成并将教程中的代码复制/粘贴到相关文件中,但到目前为止,我还看不出我输入的内容与教程中的内容有什么区别。到目前为止,建议是在函数定义中添加或删除参数user,但这并没有解决问题。触发错误的url是http://localhost:3000/rails/mailers/user_mailer/account_activation.http://localhost:3000/rails/mai