IOS_21 group_ipad neutron controller screen adaptation, ios_21 group_ipad neutron

Source: Internet
Author: User

IOS_21 group_ipad neutron controller screen adaptation, ios_21 group_ipad neutron

Finally:







Important screen adaptation techniques in iPad,

Add a contentView placeholder first,

And only set the frame in the viewDidLoad method,

Because no matter whether the horizontal or vertical screen is displayed on the iPad, W is the narrow side,

Therefore, add a contentView to the right of the master controller,

And auto Scaling with the width and height of the master controller,

The view of the sub-controller only needs to be added to the contentView. The width and height of x 0 y 0 are the bounds of the contentView.



Code snippet:

//// MainViewController. m // handsome _ buy /// Created by beyond on 14-8-13. // Copyright (c) 2014 com. beyond. all rights reserved. // master controller. The left side is the dock and the right side is the subcontroller # import "MainViewController. h "# import" Dock. h "# import" DockDelegate. h "// custom navigator # import" BeyondNavigationController. h "// controller # import" DealListController corresponding to the [four] buttons on the dock. h "# import" MapController. h "# import" CollectionController. h "# import" MineController. h "@ interface MainViewController () <DockDelegate> {// important screen adaptation tips: First add a contentView placeholder, and only set the frame in the viewDidLoad method, because W is a narrow side in both horizontal and vertical screens on the iPad, add a contentView to the right of the master controller, and make it automatically scale with the width and height of the master controller. The view of the sub-controller only needs to be added to the contentView. The width and height of x 0 y 0 is the bounds UIView * _ contentView of the contentView ;} @ end @ implementation MainViewController-(void) viewDidLoad {[super viewDidLoad]; log (@ "% @", NSStringFromCGRect (self. view. frame); self. view. backgroundColor = [UIColor whiteColor]; // 1. add the Dock to the master controller [self addDock]; // 2. important screen adaptation techniques: First add a contentView placeholder and set the frame only in the viewDidLoad method, because W is the narrow side in the iPad, whether it is a horizontal screen or a vertical screen, therefore, first add a contentView to the right of the master controller and let it automatically scale with the width and height of the master controller, while the view of the sub-controller only needs to be added to the contentView, x 0 y 0 width and height are the bounds [self addContentView] of contentView; // 3. add a total of four subcontrollers, which correspond to the top four tab buttons in the dock [self addAllChildControllers];} // 1. add the Dock to the master controller-(void) addDock {Dock * dock = [[Dock alloc] init]; // The height and right spacing are set inside the dock to automatically stretch, the width is also rewritten. The setFrame is fixed to 100 dock. frame = CGRectMake (0, 0, 0, self. view. frame. size. height); // when the internal column of the dock is clicked, you can call the proxy method (the block effect is the same) dock. delegate = self; [self. view addSubview: dock];} // 1-1, implement the dock proxy method-(void) dock :( Dock *) dock tabChangeFromIndex :( int) fromIndex toIndex :( int) toIndex {log (@ "% d -- click-% d", fromIndex, toIndex); // 1. remove the old sub-controller (wrapped in the navigation) UIViewController * oldVC = self. childViewControllers [fromIndex]; [oldVC. view removeFromSuperview]; // 2. add a new sub-controller (wrapped in the navigation) UIViewController * newVC = self. childViewControllers [toIndex]; // 3. the view of the sub-controller is directly added to the contentView, and the width and height are automatically scaled to fill the contentView. This allows you to adapt the landscape to newVC. view. autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; // The contentView can be used to adapt the portrait and landscape screens to newVC. view. frame = _ contentView. bounds; [_ contentView addSubview: newVC. view];} // 2. important screen adaptation techniques: First add a contentView placeholder and set the frame only in the viewDidLoad method, because W is the narrow side in the iPad, whether it is a horizontal screen or a vertical screen, therefore, first add a contentView to the right of the master controller and let it automatically scale with the width and height of the master controller, while the view of the sub-controller only needs to be added to the contentView, x 0 y 0 width and height are the bounds-(void) addContentView of contentView {// Add contentview to the right of the master controller _ contentView = [[UIView alloc] init]; // width: the width of the master controller-the dock width CGFloat contentViewW = self. view. frame. size. width-kDockItemW; // The height is the Controller's high CGFloat contentViewH = self. view. frame. size. height; // important, auto scaling of both width and height _ contentView. autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; // you only need to set the frame of the contentView once during view Did Load. frame = CGRectMake (kDockItemW, 0, contentViewW, contentViewH); [self. view addSubview: _ contentView];} // 3. add a total of four subcontrollers, which correspond to the top four tab buttons in the dock-(void) addAllChildControllers {// 1. group_subcontroller DealListController * dealVC = [[DealListController alloc] init]; dealVC. view. backgroundColor = [UIColor purpleColor]; BeyondNavigationController * nav = [[BeyondNavigationController alloc] initWithRootViewController: dealVC]; [self addChildViewController: nav]; // 2. _ subcontroller MapController * mapVC = [[MapController alloc] init]; mapVC. view. backgroundColor = [UIColor yellowColor]; nav = [[BeyondNavigationController alloc] initWithRootViewController: mapVC]; [self addChildViewController: nav]; // 3. collection_subcontroller CollectionController * collectionVC = [[CollectionController alloc] init]; collectionVC. view. backgroundColor = [UIColor greenColor]; nav = [[BeyondNavigationController alloc] initWithRootViewController: collectionVC]; [self addChildViewController: nav]; // 4. my _ Sub-controller MineController * mineVC = [[MineController alloc] init]; mineVC. view. backgroundColor = [UIColor blueColor]; nav = [[BeyondNavigationController alloc] initWithRootViewController: mineVC]; [self addChildViewController: nav]; // 5. and manually call the agent method of the dock. By default, the group_subcontroller [self dock: nil tabChangeFromIndex: 0 toIndex: 0] is selected.} @ end


Custom navigation controller used:

/// BeyondNavigationController. m // handsome _ buy /// Created by beyond on 14-8-14. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "BeyondNavigationController. h "@ interface BeyondNavigationController () @ end @ implementation BeyondNavigationController // optimization: this class is used for the first time. It is called when an object is instantiated and only once + (void) is called) initialize {// 1. the appearance method returns a global appearance object in the navigation bar // modifies the appearance object, which is equivalent to modifying the appearance UINavigationBar * naviBar = [UINavigationBar appearance] for the entire project; // 2. set the background image of the navigation bar (stretch one pixel from the center) [naviBar setBackgroundImage: [UIImage imageStretchedWithName: @ "bg_navigation.png"] forBarMetrics: UIBarMetricsDefault]; // 3. set the topic [naviBar setTitleTextAttributes: @ {NSForegroundColorAttributeName: [UIColor blackColor], NSShadowAttributeName: [NSValue valueWithUIOffset: UIOffsetZero]}]; // 4. similarly, modify the global appearance of all UIBarButtonItem * barBtnItem = [UIBarButtonItem appearance]; // modify the background image of the item [barBtnItem setBackgroundImage: UIControlStateNormal barMetrics: UIBarMetricsDefault]; [barBtnItem setBackgroundImage: [UIImage reported: @ "reported"] forState: UIControlStateHighlighted barMetrics: UIBarMetricsDefault]; // modify the text style NSDictionary * dict =@{ identifier: [UIColor darkGrayColor], identifier: [NSValue valueWithUIOffset: UIOffsetZero], identifier: [UIFont systemFontOfSize: 16]}; [barBtnItem setTitleTextAttributes: dict forState: UIControlStateNormal]; [barBtnItem setTitleTextAttributes: dict forState: UIControlStateHighlighted]; // 5. set the status bar style [UIApplication sharedApplication]. statusBarStyle = UIStatusBarStyleLightContent;} @ end



Dock View

//// Dock. m // handsome _ buy /// Created by beyond on 14-8-13. // Copyright (c) 2014 com. beyond. all rights reserved. // The left side of the master controller is the dock, and the right side is the sub-controller corresponding to the dock column # import "Dock. h "// more buttons at the bottom of the dock # import" DockItemMore. h "// The Last 2nd [positioning] buttons Under the dock # import" DockItemLocation. h "// The four buttons at the top of the dock (group buying, MAP, favorites, and mine) all use the instance # import" DockItemTab. h "# include" DockDelegate. h "@ interface Dock () {// The four buttons at the top of the dock (group buying, MAP, favorites, my) the selected one (the image is set to disable in White) DockItemTab * _ currentTab;} @ end @ implementation Dock-(id) initWithFrame :( CGRect) frame {self = [super initWithFrame: frame]; if (self) {// 1, set the dock to the left of the master controller and the background [self setDockPositionAndBg]; // 2. add the Group Logo [self addLogo] at the top of the dock; // 3. add the [more] button at the bottom of the dock [self addMoreBtn]; // 4. add the last 2nd [locate] buttons Under the dock [self addLocationBtn]; // 5. add the four buttons at the top of the dock (group buying, MAP, favorites, my) [self addFourTabBtn];} return self ;}// 1. Set the dock to always on the left of the master controller, and the background-(void) setDockPositionAndBg {// 1. enable Automatic scaling of the dock (height + right margin) self. autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin; // 2. set the background color of the dock and use the image to tile self. backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @ "bg_tabbar.png"];} // 2. add the Group Logo-(void) addLogo {UIImageView * logo = [[UIImageView alloc] init]; logo on the top of the dock. image = [UIImage imageNamed: @ "ic_logo.png"]; // set the size of CGFloat scale = 0.65; CGFloat logoW = logo. image. size. width * scale; CGFloat logoH = logo. image. size. height * scale; // center. Set the width and height first, and then set the center XY logo. bounds = CGRectMake (0, 0, logoW, logoH); // set the location logo. center = CGPointMake (kDockItemW * 0.5, kDockItemH * 0.5); [self addSubview: logo];} // 3. add the lower [more] button-(void) addMoreBtn {DockItemMore * moreBtn = [[DockItemMore alloc] init]; CGFloat y = self. frame. size. height-kDockItemH; // because the moreBtn button is automatically scaled, it is always at the bottom of the dock, and its parent class has fixed its width and height moreBtn. frame = CGRectMake (0, y, 0, 0); [self addSubview: moreBtn];} // 4. add the last 2nd [locate] buttons Under the dock-(void) addLocationBtn {DockItemLocation * locBtn = [[DockItemLocation alloc] init]; // because the locBtn button is automatically scaled, the last 2nd records at the bottom of the dock, and its parent class has fixed the CGFloat y = self. frame. size. height-kDockItemH * 2; locBtn. frame = CGRectMake (0, y, 0, 0); // loc. enabled = NO; [self addSubview: locBtn];} // 5. add the four buttons at the top of the dock (group buying 0, MAP 1, add to favorites 2, my 3)-(void) addFourTabBtn {// 1. use the extraction method to add a TabBtn (Group Buying) [self addOneTabBtn: @ "ic_deal.png" selectedIcon: @ "ic_deal_hl.png" index: 0]; // 2. use the extraction method to add a TabBtn (MAP) [self addOneTabBtn: @ "ic_map.png" selectedIcon: @ "ic_map_hl.png" index: 1]; // 3. use the extraction method to add a TabBtn (favorites) [self addOneTabBtn: @ "ic_collect.png" selectedIcon: @ "ic_collect_hl.png" index: 2]; // 4. add a TabBtn (my) [self addOneTabBtn: @ "ic_mine.png" selectedIcon: @ "ic_mine_hl.png" index: 3] using the extraction method; // 5. add the separator line at the bottom of the tag: UIImageView * dividerImgView = [[UIImageView alloc] init]; dividerImgView. frame = CGRectMake (0, kDockItemH * 5, kDockItemW, 2); dividerImgView. image = [UIImage imageNamed: @ "separator_tabbar_item.png"]; [self addSubview: dividerImgView];} // 5-1, use the extraction method to add a TabBtn (group buying 0, MAP 1, favorite 2, my 3), the parameter index determines the y value-(void) addOneTabBtn :( NSString *) iconName selectedIcon :( NSString *) selectedIconName index :( int) index {// (group buying, map, add to favorites, my) TabBtn uses the same parent class. They only have different Y values. DockItemTab * tab = [[DockItemTab alloc] init]; // set the button background and the selected image [tab setIcon: iconName selectedIcon: selectedIconName]; tab. frame = CGRectMake (0, kDockItemH * (index + 1), 0, 0); // because it is a tab, the [tab addTarget: self action: @ selector (tabBtnClick :) forControlEvents: UIControlEventTouchDown]; // tag 0 1 2 3 (group buying 0, MAP 1, favorites 2, my 3) tab. tag = index; [self addSubview: tab]; // The index = 0 is selected by default (Group buy 0, MAP 1, add to favorites 2, my 3) if (index = 0) {[self tabBtnClick: tab] ;}// 5-2, because the tab is added to the dock, so the dock is responsible for the task of monitoring the tab click. At the same time, the master controller has added the dock, so the master controller must be the proxy of the dock, and the dock notifies the proxy to notify the proxy, its internal tab is clicked-(void) tabBtnClick :( DockItemTab *) tab {// 0. to upload two tags, you must first notify the dock proxy (because the dock is added to the master controller, the dock proxy is the master controller) if ([_ delegate respondsToSelector: @ selector (dock: tabChangeFromIndex: toIndex :)]) {// call the proxy method, which is equivalent to the notification proxy. From which one of the buttons in the self dock is switched to the [_ delegate dock: self tabChangeFromIndex: _ currentTab. tag toIndex: tab. tag];} // 1. control status // first set the previous one to gray, because the picture is set to enable status is black _ currentTab. enabled = YES; // set the highlighted white tab when the image is disable. enabled = NO; // Finally, set the clicked button to current _ currentTab = tab;} # pragma mark 1. Rewrite the setFrame method to set its own width, prevent external changes to the width and height-(void) setFrame :( CGRect) frame {frame. size. width = kDockItemW; [super setFrame: frame] ;}@ end






















Ipad mini screen can be adapted to ipad mini2

Yes, but that's not the retina. The rest is the same. You are so bold and awesome that it will be converted! Future !!!!!!!!!!!!!!!!!!
 
IPad has been jailbroken, ONScripter has been installed, ifile has been installed, and various compatible iOS game Resources

Will you use 360 software manager?
Download a 360 software manager and find the software in the mobile phone software. download the software and install it. There are many games in it.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.