Apple offers three ways to storyboard segue:push,modal,custom .
The push Segue is a predefined jump method for the system,
In order for it to work properly, we must also load the Uinavigationcontroller.
Sometimes we don't want to see Uinavigation bar, we can use modal segue.
modal Segue has four ways to jump: Cover Vertical, Flip horizontal, cross dissolve and Partial Curl.
If the way we want to jump is different from these four ways, we can use the custom jump mode named Segue.
Here is a sample that implements the custom Segue :
1. Create a Uistoryboardsegue subclass
2. Overloaded-(void) Perform method
1- ( void) perform
2{
3Uiviewcontroller *desviewcontroller = (Uiviewcontroller *) Self.destinationviewcontroller;
4
5UIView *srcview = [(Uiviewcontroller *) Self.sourceviewcontroller view];
6UIView *desview = [Desviewcontroller view];
7
8Desview.transform = Srcview.transform;
9Desview.bounds = Srcview.bounds;
Ten
One if(islandscapeorientation)
A{
- if(Isdismiss)
-{
theDesview.center = Cgpointmake (srcview.center.x, srcview.center.y-srcview.frame.size.height);
-}
- Else
-{
+Desview.center = Cgpointmake (srcview.center.x, srcview.center.y + srcView.frame.size.height);
-}
+}
A Else
at{
- if(Isdismiss)
-{
-Desview.center = Cgpointmake (Srcview.center.x-srcview.frame.size.width, SRCVIEW.CENTER.Y);
-}
- Else
in{
-Desview.center = Cgpointmake (srcview.center.x + srcView.frame.size.width, srcview.center.y);
to}
+}
-
the
*UIWindow *mainwindow = [[UIApplication sharedapplication].windows Objectatindex: 0];
$[MainWindow Addsubview:desview];
Panax Notoginseng
- // slide Newview over Oldview and then remove Oldview
the [UIView animatewithduration: 0.3
+animations:^{
ADesview.center = Cgpointmake (srcview.center.x, SRCVIEW.CENTER.Y);
the
+ if(islandscapeorientation)
-{
$ if(Isdismiss)
${
-Srcview.center = Cgpointmake (srcview.center.x, srcview.center.y + srcView.frame.size.height);
-}
the Else
-{
WuyiSrcview.center = Cgpointmake (srcview.center.x, srcview.center.y-srcview.frame.size.height);
the}
-}
Wu Else
-{
About if(Isdismiss)
${
-Srcview.center = Cgpointmake (srcview.center.x + srcView.frame.size.width, srcview.center.y);
-}
- Else
A{
+Srcview.center = Cgpointmake (Srcview.center.x-srcview.frame.size.width, SRCVIEW.CENTER.Y);
the}
-}
$}
thecompletion:^ (BOOL finished) {
the // [Desview Removefromsuperview];
the [Self.sourceviewcontroller Presentmodalviewcontroller:desviewcontroller Animated:no];
the}];
- }
In Viewcontroller, the overloaded Prepareforsegue method
1- ( void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: ( ID) Sender
2{
3Horizontalslidesegue *s = (Horizontalslidesegue *) segue;
4S.isdismiss = NO;
5
6 if(Uideviceorientationislandscape ([Uidevice currentdevice].orientation))
7{
8S.islandscapeorientation = YES;
9}
Ten Else
One{
AS.islandscapeorientation = NO;
-}
- }
3. Choose the custom Segue setting Segue class: Customsegue (Our custom Class)
4. Call Segue Using code: