-
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:
- Block trong objective c
- Cách ép kiểu trong Objective C?
- iOS project không load được UI trên Ipad.
- Làm sao viết được ứng dụng paint trong ios
- Làm sao lưu ảnh download từ internet vào cache
- các pro chỉ em cách chèn file flash đuôi .swf và xcode với!
- Làm sao cập nhập được thay đổi từ webservice trong UITableView
- Instance method và class method khác nhau như thế nào?
- [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
- Làm sao để tạo 1 chương trình kết nối Client Server đơn giản
-
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; }
Pallet nhựa Long An đã trở thành một trong những lựa chọn phổ biến cho nhu cầu vận chuyển và lưu trữ hàng hóa trong nhiều ngành công nghiệp. Với đặc tính nhẹ nhàng, chắc chắn và dễ vận chuyển, các...
Thanh lý pallet nhựa Long An giá rẻ