现在流行什么语言建设网站,合肥市建设工程市场信息价,乐峰网网站是谁做的,做网站按钮原文摘自#xff1a;UISplitViewController的使用。UISplitViewController在ipad中的使用ipad的屏幕比iphone大#xff0c;所以在界面上#xff0c;ipad比iphone多一个UISplitViewController#xff0c;用来实现ipad在横屏时#xff0c;分两栏显示所需要的界面#xff0c…原文摘自UISplitViewController的使用。 UISplitViewController在ipad中的使用ipad的屏幕比iphone大所以在界面上ipad比iphone多一个UISplitViewController用来实现ipad在横屏时分两栏显示所需要的界面可以一边是目录一边是具体的内容。下面我将详细的阐述UISplitViewController在ipad中的使用。首先是创建一个工程ipad.demo.然后创建一个DetailViewController和RootViewController其中RootViewController继承UITableViewController。同事创建两个相应的xib文件。删除ipad_demoViewController.相应的类列表如下 然后修改ipad_demoAppDelegate.h文件#import UIKit/UIKit.h #import RootViewController.h #import DetailViewController.h class ipad_demoViewController; interface ipad_demoAppDelegate : NSObject UIApplicationDelegate { UIWindow *window; UISplitViewController *splitViewController; RootViewController *rootViewController; DetailViewController *detailViewController; } property (nonatomic, retain) IBOutlet UIWindow *window; property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController; property (nonatomic, retain) IBOutlet RootViewController *rootViewController; property (nonatomic, retain) IBOutlet DetailViewController *detailViewController; end.m文件- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after app launch. [window addSubview:splitViewController.view]; [window makeKeyAndVisible]; return YES; }修改MainWindow.xib文件添加UISplitViewController容器IB中的控件和相应的事件相联系连接过程是按住control键然后点击ipad_demo App Delegate连接到Split View Controller然后选择自定义的事件即可最后的结果如下最后在把相应的容器换成自定义的容器实现的方法是最后的结果是现在我们在实现DetailViewController 首先修改其相应的文件 .h文件修改如下#import UIKit/UIKit.h interface DetailViewController : UIViewController { IBOutlet UILabel *lable; IBOutlet UISwitch *switch1; NSIndexPath *index; } -(void)deetail:(id)sender; property (nonatomic,retain) UILabel *lable; property (nonatomic,retain) UISwitch *switch1; end .m文件修改如下#import DetailViewController.h implementation DetailViewController synthesize lable,switch1; - (void)viewDidLoad { [super viewDidLoad]; } -(void)viewWillAppear:(BOOL)animated { } -(void)deetail:(id)sender { indexsender; self.lable.text[NSString stringWithFormat:Row %d,section %d,[index row],[index section]]; if ([index row]%20) { self.switch1.onYES; }else { self.switch1.onNO; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { [super viewDidUnload]; self.lablenil; self.switch1nil; } - (void)dealloc { [self.lable release]; [self.switch1 release]; [super dealloc]; } end 2.修改相应的xib文件添加相应的控件并且相应的组建和相应的事件相关联。最后我们实现RootViewController首先修改相应的文件 .h文件如下#import UIKit/UIKit.h class DetailViewController; interface RootViewController : UITableViewController { IBOutlet DetailViewController *detailViewController; } property (nonatomic,retain) DetailViewController *detailViewController; end.m文件如下- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return 7; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier Cell; UITableViewCell *cell [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell nil) { cell [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell… cell.textLabel.text[NSString stringWithFormat:ROW %d section %d,[indexPath row],[indexPath section]]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here. Create and push another view controller. // DetailViewController *detailViewController [[DetailViewController alloc] initWithNibName:DetailViewController bundle:nil]; // [self.navigationController pushViewController:detailViewController animated:YES]; // [detailViewController release]; [detailViewController deetail:indexPath]; }2、修改相应的xib文件相应的事件和控件相联系。运行结果如下