2012-06-15 2 views
1

저는 변경, 취소 및 완료라는 세 개의 버튼이있는 UIActionsheet를 표시하려는 프로젝트에서 작업 중이며 일부 레이블이있는 UIView를 넣고 싶습니다. 나는 동적 인 UIView를 만들었고 액션 시트에 추가했다. 그러나 버튼 뒤에 숨어있어서 setFrame, bounds까지 모든 가능한 방법으로 시도했지만 해결책을 찾을 수 없었다. UIActionsheet 맨 위에이 UIView를 배치하고 버튼을 배치하고 싶습니다. 의심이 있으시면 언제든지 의견을 게시하십시오. 여기 UIView를 UIActionSheet의 서브 뷰로 추가합니다.

내 코드입니다 : 당신은, 그것은 100 개 픽셀에 의해 아래로 모든 버튼을 이동이 방법을 사용할 수 있습니다

-(IBAction)tapbutton:(id)sender 
{ 
Lablesubview *view = [[Lablesubview alloc]init]; 
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
               delegate:self 
             cancelButtonTitle:@"Cancel" 
           destructiveButtonTitle:@"Change" 
             otherButtonTitles:@"Done",nil]; 

    [actionSheet addSubview:view]; 
    [actionSheet showInView:self.view]; 
} 

답변

3

, modificaiton 이러한 유형의 응용 프로그램 제거 될 수 있음을 유의하시기 바랍니다

-(IBAction)tapbutton:(id)sender 
{ 
    //create the view 
    Lablesubview *view = [[Lablesubview alloc]init]; 
    //Set the frame 
    view.frame = CGRectMake(0, 10, 320, 100); 
    view.backgroundColor = [UIColor greenColor]; 

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                  delegate:self 
                cancelButtonTitle:@"Cancel" 
               destructiveButtonTitle:@"Change" 
                otherButtonTitles:@"Done",nil]; 

    [actionSheet showInView:self.view]; 

    CGRect rect; 

    //expand the action sheet 
    rect = actionSheet.frame; 
    rect.size.height +=100; 
    rect.origin.y -= 100; 
    actionSheet.frame = rect; 

    //Displace all buttons 
    for (UIView *vButton in actionSheet.subviews) { 
     rect = vButton.frame; 
     rect.origin.y += 100; 
     vButton.frame = rect; 
    }  


    //Add the new view 
    [actionSheet addSubview:view]; 
} 
+0

정말 고마워. 그 목적을 위해 버튼 위에 5 개의 레이블을 표시하고 싶었지만이 솔루션을 선택했지만 응용 프로그램 거부가 발생할 수 있다고 말하면 거부를 유발할 수없는 부분을 달성 할 수있는 방법이 무엇인지 말하면됩니다. – iMash

+1

나만의보기를 만들고 나만의 레이블과 단추를 추가 한 다음 [self.view addSubView : yourView]; –

+1

사실 나는 이미 당신이 위의 코멘트에서 말한 것을했습니다. 어쨌든 당신에게서 확인 됐어. 귀중한 지침에 감사드립니다. – iMash

관련 문제