有趣的事情 - 这个错误仍然存在于 iOS 7.1beta4 :)
并且没有出现在 iPhone 实现中,只有 iPad ......
它的起源很奇怪——当UIActionSheet有这么多项目时,会显示“模糊”效果,所以它必须将它们放在类似UITableView的容器中,但不幸的是,这个视图容器被放置了两次(而且它不是同一个实例)。所以我们只需要留下一个并删除其他的。
我们需要纠正的另一件事是UITableView的高度。
在我的修复下 - 在UIActionSheetDelegate中实现-(void)willPresentActionSheet:
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
if( SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") ) {
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
// fix for iOS7 iPad UIActionSheet presentation when content need to scroll
// and scrolled view appears with unnecessary copies, remove not needed ones
// and set proper tableview height too
int count = 0;
for (UIView *subview in actionSheet.subviews) {
if( [subview isMemberOfClass:[UIView class]] ) {
if( ++count == 1 ) {
// process only first view
for( UIView *subsubview in subview.subviews ) {
if( [subsubview isKindOfClass:[UITableView class]] ) {
// fix table view height
UITableView *tableView = (UITableView*)subsubview;
CGRect tableViewFrame = tableView.frame;
tableViewFrame.size.height -= subview.frame.origin.y;
tableView.frame = tableViewFrame;
}
}
} else {
// remove unnecessary view
[subview removeFromSuperview];
}
}
}
}
}
}