The basic use of popover for the ipad development of the Cat learning iOS

Source: Internet
Author: User

Cat Share, must boutique

Original articles, welcome reprint. Reprint Please specify: Sanayu's Blog
Address: http://blog.csdn.net/u013357243

One:

Two: Attention

For methods [Uipopovercontroller Dealloc] reached while popover is still visible.
When the popover is still showing, it hangs.
Don't allow popover to hang up when it's displayed.
PopOver must be dead when it's gone.

Three: Core code
- (ibaction) Popmenu: (ID) Item {//0. ContentMenuviewcontroller *menu = [[Menuviewcontroller alloc] init];//1. Create a uipopover    Uipopovercontroller*popover = [[UipopovercontrollerAlloc] initwithcontentviewcontroller:[[UinavigationcontrollerAlloc] Initwithrootviewcontroller:menu];//2. Setting Dimensions//Popover.popovercontentsize = Cgsizemake (5);    //3. From where to show-point to item[PopOver presentpopoverfrombarbuttonitem:item Permittedarrowdirections:uipopoverarrowdirectionany Animated:YES]; Self. PopOver= PopOver;}
Four: All code show Viewcontroller
#import "ViewController.h" #import "MenuViewController.h"  @interface viewcontroller ()- (ibaction) Popmenu: (ID) Item;@property(nonatomic,Strong)Uipopovercontroller*popover;@end @implementation viewcontroller - (void) Viewdidload {[SuperViewdidload];}//-[uipopovercontroller Dealloc] reached while popover is still visible.//When the popover is still showing, it 's dead.//Do not allow PopOver to hang when displayed//PopOver must be dead when it disappears./** * Popup popover Menu * *- (ibaction) Popmenu: (ID) Item {//0. ContentMenuviewcontroller *menu = [[Menuviewcontroller alloc] init];//1. Create a uipopover    Uipopovercontroller*popover = [[UipopovercontrollerAlloc] initwithcontentviewcontroller:[[UinavigationcontrollerAlloc] Initwithrootviewcontroller:menu];//2. Setting Dimensions//Popover.popovercontentsize = Cgsizemake (5);    //3. From where to show-point to item[PopOver presentpopoverfrombarbuttonitem:item Permittedarrowdirections:uipopoverarrowdirectionany Animated:YES]; Self. PopOver= PopOver;}@end
Menuviewcontroller
#import "MenuViewController.h"  @interface menuviewcontroller ()@property(nonatomic,Strong)Nsarray*titles;@end @implementation menuviewcontroller - (void) Viewdidload {[SuperViewdidload]; Self. Titles= @[@"Settings", @"Clear Cache", @"Exit", @"Basic Information"]; Self. Title= @"Menu"; Self. View. BackgroundColor= [UicolorBluecolor];CGFloatW = the;CGFloath = Self. Titles. Count* -; Self. Preferredcontentsize= Cgsizemake (W, h);//Self.contentsizeforviewinpopover = Cgsizemake (W, h);}#pragma mark-table view data source- (Nsinteger) TableView: (UITableView*) TableView numberofrowsinsection: (Nsinteger) Section {return  Self. Titles. Count;} - (UITableViewCell*) TableView: (UITableView*) TableView Cellforrowatindexpath: (Nsindexpath*) indexpath{Static NSString*id = @"Cell";UITableViewCell*cell = [TableView dequeuereusablecellwithidentifier:id];if(!cell) {cell = [[UITableViewCellAlloc] Initwithstyle:uitableviewcellstylesubtitle Reuseidentifier:id]; } cell. Textlabel. Text= Self. Titles[Indexpath. Row];returnCell;} - (void) TableView: (UITableView*) TableView Didselectrowatindexpath: (Nsindexpath*) indexpath{Uiviewcontroller*VC = [[UiviewcontrollerALLOC] init]; Vc. View. BackgroundColor= [UicolorRedcolor]; [ Self. NavigationcontrollerPUSHVIEWCONTROLLER:VC Animated:YES];}@end

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The basic use of popover for the ipad development of the Cat learning iOS

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.