在xcode 4.2上移动tableview
问题描述:
我已经阅读了如何在xcode4.2上移动一个对象,并且我成功移动了一个按钮。但我无法移动桌面视图。在xcode 4.2上移动tableview
这里是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];
}}
预先感谢您。
答
这很简单,不要忘记为表格视图创建出口。 例如,如果你的出口名称为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);
}];
}
希望这会帮助你。祝你好运
+1
我做到了。非常感谢,祝你有美好的一天:D – jackiviet 2013-03-01 09:56:40
测试表可能是'nil'。附:这种动画风格非常古老,你应该使用基于iOS 4 – borrrden 2013-03-01 05:04:58
的新模块,这个模块不工作?你的unhide方法被称为?测试表实际上是否为零? – Shaun 2013-03-01 05:07:05
@borrrden我该如何解决它?对不起,我的愚蠢问题,我对目标c完全新手。如果你给我关于“基于块的”教程,我很高兴。先谢谢你。 – jackiviet 2013-03-01 05:37:12