2013-09-26 2 views
15

iPad에서는 새로운 iOS 7 UIActionSheet가 많은 버튼으로 올바르게 표시되지 않습니다.많은 버튼이있는 Xcode iPad UIActionSheet가 올바르게 표시되지 않습니다. iOS7

스크롤 할 때 UIActionSheet의 배경을 지우지 마십시오. 버튼이 백그라운드 배경으로 고정되었습니다.

screenshot with problem

내 코드 :이 답변의 기반으로

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

:

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]; 
+0

당신이 당신의 UIActionSheet –

+0

UIActionSheet * popupQuery = [[UIActionSheet ALLOC]를 생성 코드를 추가하십시오; for (int i = 0; i <[ParamAllList count]; i ++) { NSMutableDictionary * Param = [ParamAllList objectAtIndex : i]; [popupQuery addButtonWithTitle : [매개 변수 값 : @ "name"]]; [: [popupQuery valueForKey : @ "_ buttons"] objectAtIndex : [[popupQuery valueForKey : @ "_ 단추 수] -1] setImage : [UIImage imageNamed : @"add40icon.png "] forState : UIControlStateNormal]; } popupQuery.actionSheetStyle = UIActionSheetStyleAutomatic; [popupQuery showFromRect : Button_Settings.frame inView : Button_Settings.superview animated : YES]; – Constantinus

+0

기본적으로 그림이없는 경우에도 동일한 작업을 수행합니다. UIActionSheet * popupQuery = [[UIActionSheet alloc] initWithTitle : @ "test"위임 : self cancelButtonTitle : @ ""destructiveButtonTitle : @ "Cancel"otherButtonTitles : "hi", @ "hi", @ "hi", @ "hi", @ "hi", @ "hi", @ "hi" , "hi", ""hi "," "hi", ""hi "," "hi", ""hi "," , @ "hi", @ "hi", @ "hi", @ "hi", @ "hi", nil]; 이런 식으로 엉망이됩니다 .... 버튼의 양과 관련이 있습니다. – dan

답변

24

이것은 actionSheet 대리인에 대한 내 문제를 해결했다 Change Text color in UIActionSheet Buttons

+2

- (void) willPresentActionSheet : (UIActionSheet *) actionSheet { int count = 0; for (actionSheet.subviews의 UIView * 객체) { if ([[[object class] description] isEqualToString : @ "UIView"]) { 카운트 ++; if (count == 2) { object.backgroundColor = [UIColor whiteColor]; 휴식; } } } } – Constantinus

+0

감사합니다.))))) 내 코드는 약간 투명한 배경을 남깁니다. – Constantinus

+2

잘 해결되면, 그런 문제가 있다는 것은 부끄러운 일입니다. 감사. – mashdup

2

재미있는 것은 - 이 버그 스킬 난 아이폰 OS 7.1beta4 :
에 존재 그리고 아이폰의 구현 만 아이 패드에 나타나지 않습니다 ...

그리고 그 기원은 매우 이상하다 - UIActionSheet 너무 많은 항목이있을 때 효과가 표시되고 "흐릿하게" , 따라서 이것들을 컨테이너처럼 UITableView에 넣어야하지만, 안타깝게도이 뷰 컨테이너는 두 번 배치됩니다 (동일한 인스턴스가 아닙니다). 그래서 우리는 하나만 남겨두고 다른 것들은 제거해야합니다.

우리가 수정해야 할 Antoher 것은 UITableView입니다. 내 수정 아래

-에 UIActionSheetDelegate을 구현하기 - (무효) 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]; 
        } 
       } 
      } 
     } 
    } 
} 
+0

나를 위해 (iOS 7.1) 작동하지 않습니다, 결과는 흐리게 흰색 배경 (tableView 없음)입니다. – osxdirk