我正在为 iPhone 开发一个电子商务应用程序,当用户单击即将到来的视图的按钮时,我需要立即打开一个视图,数据从服务器加载大图像,以加载我正在使用后台线程的图像。
谢谢你
很简单,以下是如何UIViewController
从IBAction
.
- (IBAction)goToNextView:(id)sender
{
//if you are using xibs use this line
UIViewController *controller = [[UIViewController alloc] initWithNibName:@"myXib" bundle:[NSBundle mainBundle]];
//if you are using storyboards use this line
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"myViewControllersID"];
//to present the controller modally use this
[self presentViewController:controller animated:NO completion:nil];
//or if you are pushing to this controller using a navigation controller use this
[self.navigationController pushViewController:controller animated:NO];
}
一定要传递动画NO
,以便立即显示视图。
您可以为此使用模态视图控制器
- (IBAction)showController:(id)sender {
SampleViewController *sampleView = [[SampleViewController alloc] init];
[self presentModalViewController:sampleView animated:YES];
}
这是教程http://timneill.net/2010/09/modal-view-controller-example-part-1/
您需要制作一个按钮,然后添加其操作,例如
-(IBAction)ButtonAction:(id)sender{
CalController *calculateView=[[CalController alloc] initWithNibName:@"CalController" bundle:nil];
[self.navigationController presentModalViewController:calculateView animated:NO];
}