1

変更、キャンセル、完了の3つのボタンでUIActionsheetを表示したいプロジェクトに取り組んでおり、タイトルの場所にいくつかのラベルがあるUIViewを配置したいと思います。動的UIViewを作成し、それをアクションシートに追加しましたが、ボタンの後ろに隠れて、setFrame、boundsのすべての可能な方法で試しましたが、解決策を見つけることができません。このUIViewをUIActionsheetの上部に配置し、その後にボタンを配置します。ご不明な点がございましたら、お気軽にコメントを投稿してください。

これが私のコードです:

-(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];
}
4

1 に答える 1

3

この方法を使用できます。すべてのボタンが100ピクセル下に移動します。このタイプの変更により、アプリケーションが拒否される可能性があることに注意してください。

-(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];
}
于 2012-06-15T13:41:53.190 に答える