15

iPad では、新しい ios 7 UIActionSheet が多くのボタンで正しく表示されません。

スクロール時に UIActionSheet の背景を消去しない。ボタンは、バックグラウンドの UIActionSheet でフリーズしているように見えます。

問題のあるスクリーンショット

私のコード:

UIActionSheet *popupQuery = [[UIActionSheet alloc]; 
for (int i=0; i<[ParamAllList count]; i++) 
{ 
    NSMutableDictionary *Param = [ParamAllList objectAtIndex:i]; 
    [popupQuery addButtonWithTitle:[Param valueForKey:@"name"]]; 
    [[[popupQuery valueForKey:@"_buttons"] objectAtIndex:[[popupQuery valueForKey:@"_buttons"] count]-1] setImage:[UIImage imageNamed:@"add40icon.png"] forState:UIControlStateNormal];
} 
popupQuery.actionSheetStyle = UIActionSheetStyleAutomatic; 
[popupQuery showFromRect:Button_Settings.frame inView:Button_Settings.superview animated:YES];
4

2 に答える 2

24

これは、actionSheet デリゲートに対する私の回避策でした。

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
    actionSheet.backgroundColor = [UIColor whiteColor];
    for (UIView *subview in actionSheet.subviews) {
        subview.backgroundColor = [UIColor whiteColor];
    }
}

この回答に基づいて: UIActionSheet ボタンのテキストの色を変更する

于 2013-10-09T15:16:38.547 に答える
2

面白いことに、このバグはまだ iOS 7.1beta4 に存在します :)
iPhone の実装では表示されず、iPad のみで表示されます...

そして、その起源は非常に奇妙です-UIActionSheetに非常に多くのアイテムがある場合、「ぼやけた」効果が表示されるため、これらをUITableViewのようなコンテナーに配置する必要がありますが、残念ながら、このビューコンテナーは2回配置されます(同じインスタンスではありません) )。したがって、1 つだけを残し、他のものを削除する必要があります。

修正する必要があるもう 1 つのことは、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];
                    }
                }
            }
        }
    }
}
于 2014-02-01T02:18:22.537 に答える