zoukankan      html  css  js  c++  java
  • Chapter 9 Editing UITableView

    Chapter 9 Editing UITableView

     

     

    1. XIB files are typically used to create the view for a view controller, but they can also be used any time you want to lay out view objects, archive them, and have them loaded at runtime. And you can load XIB file manually with NSBundle.

     

    // Load header view

    -(UIView*)headerView

    {

        if(!_headerView)

        {

            [[NSBundle mainBundle] loadNibNamed:@"HeaderView" owner:self options:nil];

        }

        

        return _headerView;

    }

     

     

    2. When a new row was inserted into tableView, the data source also need to be inserted an new object. Because the role of a view object is to present model objects to the user, updating views without updating the model objects is not very useful.

     

    3. Difference between reomveObjectIdenticalTo: and removeObject::

     

    removeObject: goes to each object in the array and sends it the message isEqual:. A class can implement this method to return YES or NO based on its own determination.

     

    removeObjectIdenticalTo:, on the other hand, removes an object if and only if it is the exact same object as the one passed in this message. 

     

     

    4. Note that simply implementing tableView:moveRowAtIndexPath:toIndexPath: caused the reordering controls to appear. The model has to implementing the reorder method.

     

    // DataSource implements tableView:moveRowAtIndexPath:toIndexPath 

    -(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath

    {

        [[BNRItemStore sharedStore] moveItemFromIndex:sourceIndexPath.row toIndex:destinationIndexPath.row];

    }

     

    // Model of Array implement 

    -(void)moveItemFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex

    {

        if(fromIndex == toIndex)

        {

            return;

        }

        

        BNRItem *item = self.privateItems[fromIndex];

        [self.privateItems removeObjectAtIndex:fromIndex];

        [self.privateItems insertObject:item atIndex:toIndex];

    }

     

     

     

     

     

     

  • 相关阅读:
    L2私有专用网 L3私有专用网 互通
    VPLS知识点
    Lab L2tpv3
    L2TP version 3(Layer 2 Tunnel Protocol)
    L2私有专用网 Interworking [IW] 的两种类型
    L2私有专用网 伪线缝补
    Option 2:End-to-End PW between Provider Edge Routers
    Option 1:专用电路互联伪线的 Inter-AS 实现
    ATOM实验
    100、拥塞控制原理听说过吗?101、如何区分流量控制和拥塞控制?
  • 原文地址:https://www.cnblogs.com/1oo1/p/3979167.html
Copyright © 2011-2022 走看看