-
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:
- Mọi ngừoi có ai sử dụng thư viện IQ widget trong objective C chưa ạ
- SVM trong OpenCV cho iOS có hỗ trợ không?
- Chơi một phần của Audio trong iOS
- Cách thay đổi kích thước của UIview???
- Mở view 2 từ view 1 trong lập trình Objective-C như thế nào?
- Code trong objective c có chạy được trong c++ không
- Làm sao để nhận biết được khi người dùng bắt đầu kết nối vào wifi?
- Cách lấy giá trị trong Mảng ứng với time hiện tại?
- Lỗi Thread 1: Signal SIGABRT
- Làm sao tăng kết nối multipeer connectivity framework ?
-
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ẻ