Привет, я сделал это, как показано ниже, это может помочь вам. Просто передайте параметр, как описано, и вы можете получить slpitview по вашему желанию.
.H файл
#import <Foundation/Foundation.h>
@class AppDelegate;
@interface CustomSplitView : NSObject
{
AppDelegate *objAppDelegate;
}
+(UIView *) setSplitView : (UIViewController *)masterView : (UIViewController*)DetailView :(CGRect)frame;
+(void) changeSplitView:(UIViewController *)DetailView :(UINavigationController *)navigationController;
@end
.M файл
#import "CustomSplitView.h"
#import "AppDelegate.h"
@implementation CustomSplitView
//*********this return view addsubview on self.view
+(UIView *) setSplitView:(UIViewController *)masterView :(UIViewController *)DetailView :(CGRect)frame
{
objAppDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate] ;
objAppDelegate.objMasterView=masterView;
objAppDelegate.objDetailView=DetailView;
//Select navigation for every split view
UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:objAppDelegate.objMasterView] autorelease];
UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:objAppDelegate.objDetailView] autorelease];
;
objAppDelegate.objSplitView.delegate=objAppDelegate;
objAppDelegate.objSplitView.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController ,nil];
objAppDelegate.objSplitView.view.frame=frame;
return (objAppDelegate.objSplitView.view);
}
+(void) changeSplitView:(UIViewController *)DetailView :(UINavigationController *)navigationController
{
objAppDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate] ;
UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:DetailView] autorelease];
objAppDelegate.objDetailView=detailNavigationController ;
// Update the split view controller's view controllers array.
// NSArray *viewControllers = [[NSArray alloc] initWithObjects:navigationController, objAppDelegate.objDetailView, nil];
// objAppDelegate.objSplitView.viewControllers= viewControllers;
objAppDelegate.objSplitView.viewControllers = [NSArray arrayWithObjects:navigationController, objAppDelegate.objDetailView ,nil];
}
@end
для разделения набора в вашем домашнем виде
Masterview *objFirstView = [[Masterview alloc] initWithNibName:@"Masterview" bundle:nil];
appdel.masterDelegate = objFirstView;
Detailview *objSecondView = [[Detailview alloc]
initWithNibName:@"Detailview" bundle:nil];
UIView *objView=[CustomSplitView setSplitView:objFirstView :objSecondView :self.view.frame];
[self.view addSubview:objView];
[objFirstView release];
[objSecondView release];