全屏弹出且可阻塞的选取视图。
在我的一个工作项目中,我需要在 UITableViewController 的 tableView 中显示一个选取视图,所以我将选取视图作为 tableView 的子视图添加。结果是这个选取视图将与 tableView 一起滚动。
我们需要一个类似于模态和阻止动作的控件,所以这里出现了 UIActionSheet
。我们必须自定义 UIActionSheet
以显示选取视图。
众所周知,UIActionSheet
不能拖入一个空的 xib,但是 UIView
可以。所以我们从一个 UIView
开始,并进行布局,然后将 UIView
的类名改为 UIActionSheet
。这对于一些基于 UIView
的控件是可行的。
使用 pop。
提供一个新方法 showInView
,并且千万不要忘记调用 [super showInView:view]
- (void)showInView:(UIView *)view doneEvent:(ActionEvent)doneEvent cancelEvent:(ActionEvent)cancelEvent
{
self.cancel.click = ^(id sender) {
if (cancelEvent) {
cancelEvent(self);
}
[self dismiss];
};
self.done.click = ^(id sender) {
if (doneEvent) {
doneEvent(self);
}
[self dismiss];
};
[super showInView:view];
}
The MIT License (MIT)
Copyright (c) 2012-2014 P.D.Q.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.