Ios ui basics 07 and iosui07

Source: Internet
Author: User

Ios ui basics 07 and iosui07

  • TableView

    • Attribute

      // Set the cell height of each row @ property (nonatomic) CGFloat rowHeight; // set the height of each set of headers @ property (nonatomic) CGFloat sectionHeaderHeight; // set the split line color @ property (nonatomic, retain) UIColor * separatorColor // set the header control @ property (nonatomic, retain) UIView * tableHeaderView; // set the table tail control @ property (nonatomic, retain) UIView * tableFooterView; // 2. high self. tableView. sectionHeaderHeight = 55; self. tableView. sectionFooterHeight = 22; // 3. set the header/tail view self of the entire tablView. tableView. tableHeaderView = [[UISwitch alloc] init]; self. tableView. tableFooterView = [UIButton buttonWithType: UIButtonTypeInfoDark]; // 4. set our split line color (clearColor is equivalent to canceling the system split line) // self. tableView. separatorColor = [UIColor clearColor]; // 5. set the split line style self. tableView. separatorStyle = UITableViewCellSeparatorStyleNone;
    • Data Source Method
      // Number of cells-(NSInteger) numberOfSectionsInTableView :( UITableView *) tableView // tell tableView the number of rows in the section Group-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section // tell tableView what is displayed in each row (every row of tableView is UITableViewCell)-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath // tell tableView the header title text in the section Group-(NSString *) tableView :( UITableView *) tableView titleForHeaderInSection :( NSInteger) section // tell tableView the ending title text of the section Group-(NSString *) tableView :( UITableView *) tableView titleForFooterInSection :( NSInteger) section // return the index title of each Group-(NSArray *) sectionIndexTitlesForTableView :( UITableView *) tableView // return the height of each cell-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath // delete data-(void) tableView :( UITableView *) tableView commitEditingStyle :( partial) editingStyle forRowAtIndexPath :( NSIndexPath *) indexPath ;//
    • Proxy Method
// As long as this method is implemented, the button function appears on the left slide (once N buttons appear on the left slide, tableView enters the editing mode, tableView. editing = YES)-(void) tableView :( UITableView *) tableView commitEditingStyle :( UITableViewCellEditingStyle) editingStyle forRowAtIndexPath :( NSIndexPath *) indexPath // button (NSArray *) displayed when the cell is left-sliding *) tableView :( UITableView *) tableView handler :( NSIndexPath *) indexPath {UITableViewRowAction * action0 = [comment rowActionWithStyle: comment title: @ "follow" handler: ^ (UITableViewRowAction * action, NSIndexPath * indexPath) {NSLog (@ "Click follow"); // detaches the button that appears on the left slide (exit edit mode) tableView. editing = NO;}]; UITableViewRowAction * action1 = [UITableViewRowAction rowActionWithStyle: deleting title: @ "delete" handler: ^ (UITableViewRowAction * action, NSIndexPath * indexPath) {[self. wineArray removeObjectAtIndex: indexPath. row]; [tableView deleteRowsAtIndexPaths: @ [indexPath] withRowAnimation: UITableViewRowAnimationAutomatic];}]; return @ [action1, action0];} // The agent method obtains the selected rows, row number-(void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath; // allows you to edit the selected row-(BOOL) tableView :( UITableView *) tableView canEditRowAtIndexPath :( NSIndexPath *) indexPath;
  • UITableViewCell

    • Attribute:
      // Set the indicator style on the right of the cell // accessoryView priority> accessoryType // cell. accessoryView = [[UISwitch alloc] init]; @ property (nonatomic) UITableViewCellAccessoryType accessoryType; // default is UITableViewCellAccessoryNone. use to set standard type
    • Cell Creation

      • Create Registration

        [Self. tableview registerClass: [UITableViewCell class] forCellReuseIdentifier: ID]; // after registration, you can directly find the created UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: ID];
      • Non-registration Creation

        • Search from cache holding first

           UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
        • Cannot be found in the created

           if (nil==cell) {cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID]; }

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.