• 4-23学习心得


    4-22 学习心得

    // 设置每组尾部View

    - (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

    // 设置每组头部View

    - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

     

    一定要注意:

         设置每组头部和尾部VIew时,一定要设置每组头部和尾部高度,不然会不显示,因为那两个方法不会执行

    // 设置每组尾部高度

    - (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

    // 设置每组头部高度

    - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

     

    // 进入编辑模式,不设置默认为NO

    //    tableView.editing = YES;

     

        [tableView setEditing:YES animated:YES];

     

        // tableView是否可以选中

    //    _tableView.allowsSelection = NO;

        // 是否可以多选

    //    tableView.allowsMultipleSelection = YES;

        // 编辑模式下是否可以多选

     

    //    tableView.allowsMultipleSelectionDuringEditing = YES;

    /* 设置编辑模式的类型,不实现的话默认为UITableViewCellEditingStyleDelete

        如果设置了 [tableView setEditing:YES animated:YES];会导致cell不能向右滑动

        看到删除按钮,要点击左边编辑模式才会出现删除按钮,向右滑动显示的只能

        是删除按钮,添加的模式只会出现在编辑模式为YES情况下cell的左边

    */

    - (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath

    {

        return UITableViewCellEditingStyleDelete;

    }

    // 虽然这代理方法是可选的,但是不实现的话将不会出现向右滑动的删除按钮

    - (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

    {

        if (editingStyle == UITableViewCellEditingStyleInsert) {

            NSLog(@"454564");

        }

     

    }

     

    赋值数组时注意不能直接赋值,最好用arrayWithArray:方法来进行数组和数组之间的赋值

    例如

    NSArray *array1 = [NSArray arrayWithObjects:@"啦啦啦",@"哈哈哈",@"嘿嘿嘿",@"呜呜呜", nil];

    self.array1 = [NSMutableArray arrayWithArray:array1];

    NSArray 允许程序员把任何对象存进去,存进去是什么出来就是什么,使用的时候要进行强制类型转换。

    例如:

    NSArray *myArray;

    NSArray *myArray2;

    NSDate *aDate = [NSDate distantFuture];

    NSValue *aValue = [NSNumber numberWithInt:5];

    NSString *aString = @"a string";

     

    myArray = [NSArray arrayWithObjects:aDate, aValue, aString, nil];//3 object

    myArray2=[myArray arrayByAddingObject:@"test"];//4 object 

     

    arrayByAddingObject:在当前数据中追加一个新的对象,并且返回一个新的数据对象(新的数组对象和被追加的对象,是两个不同的数组对象)。

  • 相关阅读:
    PTA(Advanced Level)1063.Set Similarity
    PTA(Advanced Level)1047.Student List for Course
    PTA(Advanced Level)1023.Palindromic Number
    PTA(Advanced Level)1023.Have Fun with Numbers
    PTA(Basic Level)1017.A除以B
    PTA(Advanced Level)1059.Prime Factors
    PTA(Advanced Level)1096.Consecutive Factors
    expected primary-expression before xx token错误处理
    PTA(Advanced Level)1078.Hashing
    PTA(Advanced Level)1015.Reversible Primes
  • 原文地址:https://www.cnblogs.com/pocket-mood/p/4451346.html
Copyright © 2020-2023  润新知