大佬教程收集整理的这篇文章主要介绍了使用Xamarin.iOS在单击处理程序中添加UICollectionViewCell中的按钮,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
collectionView.RegisterNibForCell (DocumentViewCell.Nib,docCellId); ... public override UICollectionViewCell GetCell (UICollectionView collectionView,MonoTouch.Foundation.NSIndexPath indexPath) { var docCell = (DocumentViewCell)collectionView.DequeueReusableCell (docCellId,indexPath); docCell.btndelete.Hidden = !EditMode; docCell.btndelete.TouchUpInside += delegate(object sender,EventArgs E) { Logging.Debug("Crashes before if reaches here"); }; return docCell; }
我知道单元格开始被重用,这很可能在发生这种情况时不起作用,但现在当按下删除按钮时,它只会立即崩溃,只有一个元素在列表中.一切都很好,直到我按下按钮然后我得到下面的堆栈跟踪.基于我的UITableView代码几乎完全相同,我认为没有理由发生这种情况.
有没有人使用基于Nib的CollectionView单元格完成此操作?任何帮助非常感谢!
堆栈跟踪:
at (wrapper managed-to-nativE) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,String[],intptr,intptr) <IL 0x0009f,0xffffffff> at MonoTouch.UIKit.UIApplication.Main (String[],String,String) [0x0004c] in /Developer/MonoTouch/source/monotouch/src/UIKit/UIApplication.cs:38 at SALEsApp.Application.Main (String[]) [0x00000] in /MyApp/Main.cs:18 at (wrapper runtime-invokE) <Module>.runtime_invoke_void_object (object,intptr) <IL 0x00050,0xffffffff> Native stacktrace: 0 SALEsApp 0x0009a85c mono_handle_native_sigsegv + 284 1 SALEsApp 0x0000e138 mono_sigsegv_signal_handler + 248 2 libsystem_c.dylib 0x990a78cb _sigtramp + 43 3 ??? 0xffffffff 0x0 + 4294967295 4 UIKit 0x01990258 -[UIApplication sendAction:@R_77_10586@rget:fromSender:forEvent:] + 61 5 UIKit 0x01a51021 -[UIControl sendAction:to:forEvent:] + 66 6 UIKit 0x01a5157f -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578 7 UIKit 0x01a506e8 -[UIControl touchesEnded:withEvent:] + 546 8 UIKit 0x01c541d3 _UIGestureRecognizerupdate + 7407 9 CoreFoundation 0x03ecbafe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
更新
这段代码工作正常
public override UICollectionViewCell GetCell (UICollectionView collectionView,MonoTouch.Foundation.NSIndexPath indexPath) { var docCell = (DocumentViewCell)collectionView.DequeueReusableCell (DocumentViewCell.Key,indexPath); docCell.btndelete.Hidden = !EditMode; docCell.btndelete.TouchUpInside -= HandleTouchUpInside; docCell.btndelete.TouchUpInside += HandleTouchUpInside; return docCell; } void HandleTouchUpInside (object sender,EventArgs E) { Logging.Debug("No crash"); }
以上是大佬教程为你收集整理的使用Xamarin.iOS在单击处理程序中添加UICollectionViewCell中的按钮全部内容,希望文章能够帮你解决使用Xamarin.iOS在单击处理程序中添加UICollectionViewCell中的按钮所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。