正如您在屏幕截图中看到的,我在IB中添加了一个UIView(名为SearchView)来控制我的代码。
http://i.stack.imgur.com/cIs3e.png
如何以编程方式在代码中加载UIView?
感谢。
答案 0 :(得分:0)
以编程方式加载UIView的FlipView方法
在.h文件中使用此代码
@interface MainViewController : UIViewController {
IBOutlet UIView *secondaryView;
}
- (IBAction)toggleView:(id)sender; //Action for toggle view
- (IBAction)returnView:(id)sender;
@end
在.m
- (IBAction)toggleView:(id)sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:[self view]
cache:YES];
[[self view] addSubview:secondaryView];
[UIView commitAnimations];
}
//Flips to front when "Done" is pressed
- (IBAction)returnView:(id)sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:[self view]
cache:YES];
[secondaryView removeFromSuperview];
[UIView commitAnimations];
}
如果有任何混淆,您可以查看本教程http://www.vimeo.com/5653713。