ipad Development-The setup of the PopOver interface (mainly for the use of the device, and monitoring)

Source: Internet
Author: User

I. Building the main interface,. Set self . Navigationitem. The Leftbarbuttonitems property.

    • Because Leftbarbuttonitem is created from a xib file, controls created by Xib change by default following the size of the parent control

    • Workaround: Cancel the Xib AutoLayout, cancel the xib height auto stretch and width auto stretch

    

    • Custom controls require the outside world to change the displayed picture and text, so the following methods are available to set the picture and text that you display

Two. Leftbarbuttonitem is displayed by PopOver after clicking, and it shows a cascading menu with two TableView, which customizes the view of the cascading menu (Lrtableview below). Add the custom control to the corresponding controller. But Lrtableview needs to be provided with data to display the desired content.

    • Workaround one: To provide a model data to be displayed externally, this method causes the Lrtableview to be too dependent on the model properties, if the model attributes too much, not only to determine what the model passed, but also not control
    • Solution Two: Imitation of Apple's TableView, to their own Lrtableview also write a data source, write a proxy (this is used here), Lrtableview need data when you do not have to rely on model properties, directly ask data source to data.

Data source Protocol:

Agent Agreement:

  • The method of directly invoking the data source when the Lrtableview internal needs data
    1 #pragmaMark-uitableviewdatasource2-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section3 {4     if(TableView = = Self.lefttableview) {//table on the left5         //get the number of rows from the data source6         return[Self.datasource numberofrowsinlrviewwithlrview:self];7}Else{//the table on the right8         returnSelf.subCategories.count;9     }Ten } One  A-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath - { -UITableViewCell *cell =Nil; the     if(TableView = = Self.lefttableview) {//table on the left -         //Create the cell on the left -Cell =[Chaosleftcell Leftcellwithtableview:tableview]; -         //get the name of the corresponding row from the data source +Cell.textLabel.text =[Self.datasource lrview:self leftTitleInRow:indexPath.row]; -         //set up a picture from a data source +         if([Self.datasource respondstoselector: @selector (lrview:imagenameforrow:)]) { A              atNSString *imagename =[Self.datasource lrview:self imageNameForRow:indexPath.row]; -Cell.imageView.image =[UIImage imagenamed:imagename]; -         } -         //set a highlight picture from a data source -         if([Self.datasource respondstoselector: @selector (lrview:highlightimagenameforrow:)]) { -              inNSString *highlightimage =[Self.datasource lrview:self highlightImageNameForRow:indexPath.row]; -Cell.imageView.highlightedImage =[UIImage imagenamed:highlightimage]; to         } +          -}Else{//the table on the right the         //Create the cell on the right *Cell =[Chaosrightcell Rightcellwithtableview:tableview]; $         Panax NotoginsengCell.textLabel.text =Self.subcategories[indexpath.row]; -     } the     returncell; + } A  the #pragmaMark-uitableviewdelegate +- (void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath - { $     if(TableView = = Self.lefttableview) {//table on the left $         //Remove the child data and save -Self.subcategories =[Self.datasource lrview:self subDataOfLeftRow:indexPath.row]; -         //Refresh Data the [Self.righttableview Reloaddata]; -         //Click on the leftWuyi         if([Self.Delegaterespondstoselector: @selector (lrview:didselectedleftrow:)]) { the[Self.Delegatelrview:self DidSelectedLeftRow:indexPath.row]; -         } Wu}Else{//the table on the right -          About         if([Self.Delegaterespondstoselector: @selector (lrView:didSelectedRightRow:andLeftRow:)]) { $[Self.Delegatelrview:self didSelectedRightRow:indexPath.row Andleftrow:[self.lefttableview Indexpathforselectedrow].row]; -         } -     } -}

  • The corresponding controller realizes the Lrtableview data source method
  • Implement the Proxy method, click on the cell in the Lrtableview notification, accept the notification of the view or controller to modify Barbuttonitem text and pictures
  • Navigationcontroller's stack top controller monitors Lrtableview notifications that are clicked, and re-sets the text or image of the custom Barbuttonitem based on the data passed in the model. Finally, remember to remove the notification

ipad Development-The setup of the PopOver interface (mainly for the use of the device, and monitoring)

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.