IOS_21 group_pover for iPad horizontal and vertical screen switching, ios_21ipad

Source: Internet
Author: User

IOS_21 group_pover for iPad horizontal and vertical screen switching, ios_21ipad

Finally:



Code snippet:

//// DockItemLocation. m // handsome _ buy /// Created by beyond on 14-8-13. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "DockItemLocation. h "// click locationBtn on the dock. The Popover encapsulated controller is displayed. The search bar is displayed at the top and tableView # import" CityLocationController at the bottom. h "// the picture above the button, and the text below, which is the proportion of the picture in height # define kImageHeightRatioInBtn 0.5 @ interface DockItemLocation () <UIPopoverControllerDelegate> {// popover controller, after it is created, the show method is displayed, so it is not allowed. It is a local variable and must be remembered using the member variable. Otherwise, the method btnClick is destroyed after the call is completed. How can I display the pinch? UIPopoverController * _ popoverCtrl;} @ end @ implementation DockItemLocation-(id) initWithFrame :( CGRect) frame {self = [super initWithFrame: frame]; if (self) {// 1. call the method of the parent class and set the internal image [self setIcon: @ "ic_district.png" selectedIcon: @ "ic_district_hl.png"]; // 2. auto scaling self. autoresizingMask = UIViewAutoresizingFlexibleTopMargin; // 3. set the default text [self setTitle: @ "中"" forState: UIControlStateNormal]; self. titleLabel. f Ont = [UIFont systemFontOfSize: 16]; self. titleLabel. textAlignment = NSTextAlignmentCenter; [self setTitleColor: [UIColor whiteColor] forState: UIControlStateDisabled]; [self setTitleColor: [UIColor grayColor] forState: UIControlStateNormal]; // 4. set image attributes self. imageView. contentMode = UIViewContentModeCenter; // 5. click [Location] to display a Popover controller [self addTarget: self action: @ selector (locationBtnOnDockClic Ked) forControlEvents: UIControlEventTouchDown];} return self;} // 5. click [Location] for the listener. A Popover controller (void) locationBtnOnDockClicked {// disabled. You can click self only once. enabled = NO; // click locationBtn on the dock. The Popover encapsulated controller is displayed. The search bar is displayed at the top, and tableView CityLocationController * cityVC = [[CityLocationController alloc] init] at the bottom. // The only controller that does not inherit from UIViewController. It inherits from NSObject // popover controller. After the controller is created, the show method is displayed. Therefore, it cannot be a local variable, the member variables must be remembered; otherwise, Method B After tnClick is called, it will be destroyed. How can I display the pinch? _ PopoverCtrl = [[UIPopoverController alloc] initWithContentViewController: cityVC]; // set the display size of the Popover controller _ popoverCtrl. popoverContentSize = CGSizeMake (320,480); // proxy, listen to the XX Event _ popoverCtrl of the Popover controller. delegate = self; // because other methods need to be displayed, _ popoverCtrl is selected as the custom method [self showPopoverCtrl]; // when the screen is rotated, the position pointed to by the pop-up popover is incorrect. Therefore, it is necessary to register a notification to listen to the screen rotation. // remove the listener first to ensure robustness [[nsicationicationcenter defacenter center] removeObserver: sel F name: jsonobject: nil]; // Add another listener. Once the device has a UIDeviceOrientationDidChangeNotification, the system calls the [[nsicationicationcenter ultcenter] addObserver: self selector: @ selector (screenDidRotated) name: UIDeviceOrientationDidChangeNotification object: nil];} // 5-1, because the screen is rotated, _ popoverCtrl must be displayed again, so the custom method-(void) showPopoverCtrl {// Where is the display? If the target view is self, the rect uses bounds because the origin of bounds is relative to itself. // if the target view is self. superView, The rect uses frame, because the origin of the frame is relative to the parent control [_ popoverCtrl presentpoverfromrect: self. bounds inView: self permittedArrowDirections ctions: UIPopoverArrowDirectionAny animated: YES];} // 5-2. Add another listener. Once the listener appears on the device, the selector method (void) of the observer is called) screenDidRotated {if (_ popoverCtrl. popoverVisible) {// 1. close the _ popoverCtrl [_ poverctrl dismissPopoverAnimated: NO] above the previous position; // 2. after 0.5 seconds, create the _ popoverCtrl [self owned mselector: @ selector (showpoverctrl) withObject: nil afterDelay: 0.5] ;}# pragma mark-popOver proxy method-(void) popoverControllerDidDismissPopover :( UIPopoverController *) before the popoverController {// disappears, let the locate button restore and click the status self. enabled = YES; // before the message disappears, that is, when the popover is destroyed, the registered listener (notification) [[[nsicationicationcenter defacenter center] removeObserver: self name: UIDeviceOrientationDidChangeNotification object: nil] is removed;} # When pragma mark is destroyed, the current screen listening to the Controller is removed to prevent the wild pointer-(void) dealloc {[[nsicationicationcenter defacenter center] removeObserver: self];} # pragma mark-Override adjust image and text in the Frame-(CGRect) imageRectForContentRect :( CGRect) contentRect {CGFloat btnW = contentRect. size. width; CGFloat imgH = contentRect. size. height * weight; return CGRectMake (0, 0, btnW, imgH);}-(CGRect) titleRectForContentRect :( CGRect) contentRect {CGFloat btnW = contentRect. size. width; CGFloat textH = contentRect. size. height * (1-kImageHeightRatioInBtn); // The text is below, and the image is above CGFloat textY = contentRect. size. height-textH; return CGRectMake (0, textY, btnW, textH);} @ end








The ipad cannot be switched between landscape and Landscape

This problem also exists on your iPad. Just solve it, let's share it.
It's easy to find the solution by following the steps:
1: First, check whether the screen switching is locked: set-General-the option used by the side switch: Lock the screen. Click the side switch to make sure that the screen is not locked. Then, you can see whether the iPad can be converted horizontally or vertically. If not, go to step 2.
2: as the sub-device often times to switch between the horizontal and vertical screens to lock, and the sub-device often does not have to worry about it, the iPad horizontal and vertical screen switching is slow to reflect. I am in the second case. Solution: Disable and restart the iPad. Press the sleep key and press the screen to display the scroll bar to close the iPad. Press the sleep key to enable the iPad.
3: If the above two methods cannot be solved, it is because the iPad hardware has a problem and needs to be repaired.
Finally, we should remind you that the iPad needs to be shut down for maintenance. Hope to help you

How does one set horizontal and vertical screen switching for ipad?

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.