cmu*_*ler 2 xcode objective-c storyboard ios ios5
现在UIButton我的故事板中有一个设置,可以推送到Table View Controller.这是按预期工作的.我想要做的是在UIButton按下时加载一个xml文件并仍然移动到表视图控制器上.
我怎样才能做到这一点?我已经有了XML代码的代码,这是代码将去哪里以及如何为新的ViewController子类添加.h和.m文件的问题UIViewController.如何将这些文件链接到UIButton我在故事板中创建的文件?
将按钮连接拖到新视图,然后选择自定义Segue而不是Push或Modal.

将新的自定义Segue的类更改为"mySegueClass1"或者您想要调用它.

创建一个新的Objective-C类,其名称与刚分配给自定义segue的名称相同.
然后在mySegueClass1.m文件中添加以下代码,并添加您想要的其他操作 -(void)perform
-(void)perform{
UIViewController *dst = [self destinationViewController];
UIViewController *src = [self sourceViewController];
[dst viewWillAppear:NO];
[dst viewDidAppear:NO];
[src.view addSubview:dst.view];
CGRect original = dst.view.frame;
dst.view.frame = CGRectMake(dst.view.frame.origin.x, 0-dst.view.frame.size.height, dst.view.frame.size.width, dst.view.frame.size.height);
[UIView beginAnimations:nil context:nil];
dst.view.frame = CGRectMake(original.origin.x, original.origin.y, original.size.height, original.size.width);
[UIView commitAnimations];
[self performSelector:@selector(animationDone:) withObject:dst afterDelay:0.2f];
}
- (void)animationDone:(id)vc{
UIViewController *dst = (UIViewController*)vc;
UINavigationController *nav = [[self sourceViewController] navigationController];
[nav popViewControllerAnimated:NO];
[nav pushViewController:dst animated:NO];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3888 次 |
| 最近记录: |