Tôi có hai UIViewControllers được chứa trong bộ điều khiển chế độ xem điều hướng và cả ở chế độ ngang. Tôi muốn chuyển đổi giữa hai uiviewcontroller mà không có một hình ảnh động như push. Vì vậy, tôi thực hiện một khoảng cách tùy chỉnh giữa hai người dùng này nếu người dùng nhấp vào nút xem điều khiển đầu tiên một nút.ios: Phân đoạn tùy chỉnh giữa hai chế độ xem trong chế độ ngang
#import <Foundation/Foundation.h>
#import "AppDelegate.h"
@class AppDelegate;
@interface NonAnimatedSegue : UIStoryboardSegue {
}
@property (nonatomic,assign) AppDelegate* appDelegate;
@end
Và đây thực hiện:
#import "NonAnimatedSegue.h"
@implementation NonAnimatedSegue
@synthesize appDelegate = _appDelegate;
-(void) perform{
self.appDelegate = [[UIApplication sharedApplication] delegate];
UIViewController *srcViewController = (UIViewController *) self.sourceViewController;
UIViewController *destViewController = (UIViewController *) self.destinationViewController;
[srcViewController.view removeFromSuperview];
[self.appDelegate.window addSubview:destViewController.view];
self.appDelegate.window.rootViewController=destViewController;
}
@end
Trong kịch bản tôi chuyển sang segue tùy chỉnh và thực sự nó hoạt động tốt. Vấn đề duy nhất là uiviewcontroller thứ hai không được hiển thị ở chế độ nằm ngang mà là trong protrait. Nếu tôi loại bỏ các segue tùy chỉnh và thay thế nó bằng một segue đẩy sau đó tất cả mọi thứ hoạt động tốt, các viewcontroller thứ hai được hiển thị trong chế độ phong cảnh.
Vì vậy, tôi phải làm gì để chế độ xem thứ hai cũng ở chế độ xem ngang nếu tôi sử dụng phân đoạn tùy chỉnh của mình?
Bạn là một con người đẹp. –