xmartlabs/XLForm

formViewController assumes XLFormViewController is in the responder chain

Open

#720 创建于 2016年2月5日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)Objective-C (5,786 star) (969 fork)batch import
help wanted

描述

The method formViewController in XLFormBaseCell.m tries to get the form VC associated with the cell by climbing up the responder chain until it hits any VC. This seems like a bad assumption and here's why:

It's a generally accepted practice to have a VC (A) own another VC (B) using the child view controller array and add B's view to A. In that case, B will no longer be in the responder chain (I actually didn't know this, go figure) and the assumption made above is then violated. I have a case like this because I'm using the view of an XLFormVIewController as a subview of a monolithic VC. This is breaking the formViewController method and wreaking all sorts of havoc.

My interim fix will be to overwrite that method with a category extension to do some special logic that handles my case. In general, though, maybe cells should just keep a weak reference to their XLFormViewController if they really need it? This feels like a more sound approach.

贡献者指南