我的一个页面上有一个UISegmentedControl。我想要一个编辑框,当一个片段被点击时,被点击的片段的正下方。我希望它是动画的(幻灯片之类的)
这个是可能的吗?做这件事最好的方法是什么?
见鬼,我忘了提到所有这些动作都将发生在一个单元格中,而不是一个简单的视图中。
发布于 2010-08-12 15:40:09
您可以尝试UIView动画。首先设置您的编辑框(我猜是UITextView ??)到x坐标320 (这样它就不会出现)。其次,当用户点击分段控件时,只需使用UIView动画转换您的UITextView:
[UIView beginAnimation:nil context:nil];
[UIView setAnimationDuration: 1.0];
CGAffineTransform trans = CGAffineTransformMakeTranslation(-320, 0);
self.view.transform = trans;
[UIView commitAnimations];希望它能帮助你;)。
发布于 2010-08-12 17:56:01
好的,我会试着说得更准确些,我猜你是在使用Interface Builder吧?所以你必须将一个动作“链接”到你的UISegmentedController,所以在你的类中编写这个方法:
-(IBAction) translateMyView
{
//If the first segment is selected do translation of the cellView
if(yourSegmentedController.selectedSegmentIndex == 0)
{
[UIView beginAnimation:nil context:nil];
[UIView setAnimationDuration: 1.0];
//This will translate the view to its position from its position -320 px
CGAffineTransform trans = CGAffineTransformMakeTranslation(-320, 0);
//Replace self.view with the view you want to translate.
self.view.transform = trans;
[UIView commitAnimations];
}
else if(yourSegementedController.selectedSegmentIndex ==1)
{
//Do same thing that above but with another view
}
}因此,这就是在segmentedController中选择索引时所发生的操作。您需要做的是将此操作链接到接口生成器中的UISegmentedController。
希望对您有所帮助;-)
https://stackoverflow.com/questions/3465157
复制相似问题