0

xcode4.2でオブジェクトを移動する方法を読みましたが、ボタンの移動に成功しました。しかし、テーブルビューを移動できません。

Viewcontroller.m のコードは次のとおりです。

- (IBAction) unhide {
if (flag==1) {
    flag=0;

    CGRect frame = testtable.frame;
    frame.origin.x = frame.origin.x; // new x coordinate
    frame.origin.y = 150; // new y coordinate



    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration: 0.25];
    testtable.frame = frame;
    [UIView commitAnimations];


}
else{
    flag=1;

    CGRect frame = testtable.frame;
    frame.origin.x = frame.origin.x; // new x coordinate
    frame.origin.y = 350; // new y coordinate



    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration: 0.25];
    testtable.frame = frame;
    [UIView commitAnimations];


}}

前もって感謝します。

4

1 に答える 1

0

これは非常に簡単です。テーブル ビューのアウトレットを作成することを忘れないでください。たとえば、アウトレット名が testTable の場合、次のコード ブロックを試してください。

if(flag==0)
{
    flag=1;
    [UIView animateWithDuration:0.7 animations:^()
     {
         testTable.frame=CGRectMake(0, 150, testTable.frame.size.width, testTable.frame.size.height);
     }];
}
else
{
    flag=0;
    [UIView animateWithDuration:0.7 animations:^()
     {
         testTable.frame=CGRectMake(0, 350, testTable.frame.size.width, testTable.frame.size.height);
     }];
}

これがあなたを助けることを願っています。幸運を

于 2013-03-01T06:30:42.787 に答える