-
21-09-2011, 09:29 AM #1Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Splitview + navigationbar tự code bằng tay lỗi không hiện ?
mình thêm đoạn code này mà vẫn không đc
[navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES];
câu hỏi được rất nhiều người trên mạng hỏi như thế này:
http://stackoverflow.com/questions/4987394/uisplitviewcontrollerdelegate-willhideviewcontroller-not-sending-a-uibarbut
http://stackoverflow.com/questions/5618354/why-my-button-sometimes-disappears
http://stackoverflow.com/questions/7365153/barbuttonitem-for-splitviewcontroller-not-shown-on-screen
http://useyourloaf.squarespace.com/blog/2010/6/14/using-an-image-for-the-uisplitviewcontroller-popover-button.html
mình sửa lại như thế này thì hiện lên nhưng không chọn được
Mã:/* File: FirstDetailViewController.m */ #import "FirstDetailViewController.h" @implementation FirstDetailViewController @synthesize toolbar; #pragma mark -#pragma mark View lifecycle - (void)viewDidUnload { [super viewDidUnload]; self.toolbar = nil;}// Called when rotating to a portrait orientation.- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc { barButtonItem.title = @"Root List"; NSMutableArray *items = [[toolbar items] mutableCopy]; [items insertObject:barButtonItem atIndex:0]; [toolbar setItems:items animated:YES]; [items release]; popoverController = pc;}#pragma mark -#pragma mark Managing the popover - (void)showRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem { // Add the popover button to the toolbar. NSMutableArray *itemsArray = [toolbar.items mutableCopy]; [itemsArray insertObject:barButtonItem atIndex:0]; [toolbar setItems:itemsArray animated:NO]; [itemsArray release];} - (void)invalidateRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem { // Remove the popover button from the toolbar. NSMutableArray *itemsArray = [toolbar.items mutableCopy]; [itemsArray removeObject:barButtonItem]; [toolbar setItems:itemsArray animated:NO]; [itemsArray release];} #pragma mark -#pragma mark Rotation support - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES;} #pragma mark -#pragma mark Memory management - (void)dealloc { [toolbar release]; [super dealloc];} @end
Mã:/* File: AppDelegate.m */ #import "AppDelegate.h"#import "RootViewController.h" @implementation AppDelegate @synthesize window, splitViewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; firstDetail1 = [[FirstDetailViewController alloc] initWithNibName:@"FirstDetailView" bundle:nil]; splitViewController = [[UISplitViewController alloc] init]; splitViewController.viewControllers = [NSArray arrayWithObjects:navigationController, firstDetail1, nil]; splitViewController.delegate = firstDetail1; [window addSubview:splitViewController.view]; [window makeKeyAndVisible]; return YES;} - (void)dealloc { [splitViewController release]; [window release]; [super dealloc];} @end
View more random threads:
- [Thắc mắc] Cách sử dụng thư viện dựng sẵn igraph.h dành cho C++ trên VS 2013
- Phép chia lấy phần dư của một số thập phân cho số nguyên. Lỗi invalid operands of types `double' and `int' to binary
- Làm thế nào để lấy về link mp3 từ trang mp3.zing.vn
- Làm sao viết được ứng dụng paint trong ios
- Xử lí video và phát real-time
- Thông báo Lỗi "nib but the view outlet was not set"
- How can I create gantt Chart in IOS objective C
- Lấy khoảng cách từ (camera)iphone xuống mặt đất, sử dụng GPS và CLLocationManager.
- MainWindow.xib có tác dụng gì??
- Cách add appropriate class Trong Xcode?
-
22-09-2011, 05:47 PM #2Junior Member
- Ngày tham gia
- Sep 2015
- Đang ở
- Hà Nội
- Bài viết
- 0
Mã:Creating a Split View Controller Programmatically To create a split view controller programmatically, create a new instance of the UISplitViewController class and assign view controllers to its two properties. Because its contents are built on-the-fly from the view controllers you provide, you do not have to specify a nib file when creating a split view controller. Therefore, you can just use the init method to initialize it. Listing 5-2 shows an example of how to create and configure a split view interface at launch time. You would replace the first and second view controllers with the custom view controller objects that present your application’s content. The window variable is assumed to be an outlet that points to the window loaded from your application’s main nib file. Listing 5-2 Creating a split view controller programmatically - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MyFirstViewController* firstVC = [[[MyFirstViewController alloc] initWithNibName:@"FirstNib" bundle:nil] autorelease]; MySecondViewController* secondVC = [[[MySecondViewController alloc] initWithNibName:@"SecondNib" bundle:nil] autorelease]; UISplitViewController* splitVC = [[UISplitViewController alloc] init]; splitVC.viewControllers = [NSArray arrayWithObjects:firstVC, secondVC, nil]; [window addSubview:splitVC.view]; [window makeKeyAndVisible]; return YES; }
Ngọc Bích xanh bản chất thuộc dòng đá đá hoa (jade). Và cẩm thạch là tên gọi chung của ngọc bích. Vì thực chất chúng thuộc dòng đá đa khoáng được hình thành từ chất Silicat dưới dạng dioxy. Ngọc bích...
Chia sẻ Vòng tay ngọc bích xanh là...