zoukankan      html  css  js  c++  java
  • (素材源代码) 猫猫学iOS 之UIDynamic重力、弹性碰撞吸附等现象牛逼Demo

    猫猫分享,必须精品

    原创文章,欢迎转载。

    转载请注明:翟乃玉的博客
    地址:http://blog.csdn.net/u013357243

    一:效果

    这里写图片描写叙述
    这里写图片描写叙述
    这里写图片描写叙述
    这里写图片描写叙述
    这里写图片描写叙述

    二:代码

    #import "ViewController.h"
    #import "DemoViewController.h"
    
    @interface ViewController ()
    {
        // 功能名称的数组
        NSArray *_functions;
    }
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        _functions = @[@"吸附行为", @"推动行为", @"刚性附加行为", @"弹性附加行为", @"碰撞检測"];
    }
    
    #pragma mark - 数据源方法
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return _functions.count;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // 使用Storyboard建立的UITabeViewController,当中的Cell是已经注冊过的
        static NSString *ID = @"Cell";
        // 永远都会找到一个单元格,假设缓冲池中没有,会自己主动新建
        /**
         dequeueReusableCellWithIdentifier 直接查询可重用单元格
         dequeueReusableCellWithIdentifier:forIndexPath: 查询“注冊的”可重用单元格,此方法中indexPath本身没实用处
    
            * 强制推断是否注冊了单元格
    
         假设已经注冊过单元格,以上两个方法等效。
    
         假设在StoryBoard中指定了单元格的可重用标示符,单元格的优化将有系统接管,不再须要推断cell == nil
         */
    //    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID forIndexPath:indexPath];
    
    //    if (cell == nil) {
    //        NSLog(@"come here");
    //        
    //        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    //    }
    
        cell.textLabel.text = _functions[indexPath.row];
    
        return cell;
    }
    
    #pragma mark - 代理方法
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        DemoViewController *controller = [[DemoViewController alloc] init];
    
        // 指定标题
        controller.title = _functions[indexPath.row];
        controller.function = indexPath.row;
    
        [self.navigationController pushViewController:controller animated:YES];
    }
    
    #import "DemoViewController.h"
    #import "DemoView.h"
    #import "SnapView.h"
    #import "PushView.h"
    #import "AttachmentView.h"
    #import "SpringView.h"
    #import "CollisionView.h"
    
    @interface DemoViewController ()
    
    @end
    
    @implementation DemoViewController
    
    //- (void)loadView
    //{
    //    self.view = [[DemoView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
    //}
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        NSLog(@"功能代号: %d", self.function);
        // 在此依据实际的功能代号载入实际的视图
    
        DemoView *demoView = nil;
        switch (self.function) {
            case kDemoFunctionSnap:
                demoView = [[SnapView alloc] initWithFrame:self.view.bounds];
                break;
            case kDemoFunctionPush:
                demoView = [[PushView alloc] initWithFrame:self.view.bounds];
                break;
            case kDemoFunctionAttachment:
                demoView = [[AttachmentView alloc] initWithFrame:self.view.bounds];
                break;
            case kDemoFunctionSpring:
                demoView = [[SpringView alloc] initWithFrame:self.view.bounds];
                break;
            case kDemoFunctionCollision:
                demoView = [[CollisionView alloc] initWithFrame:self.view.bounds];
                break;
            default:
                break;
        }
    
        [self.view addSubview:demoView];
    }
    
    
    @end
    

    主要框框就这样啦。贴出了的代码只部分

    三:素材代码下载地址

    代码上传中。

  • 相关阅读:
    MATLAB调用VISUAL STUDIO 编写的C++函数
    卡尔曼滤波
    资料(不定时更新)
    20201207-总结
    20201126-1 每周例行报告
    20201120-1 每周例行报告
    作业要求 20201112-1 每周例行报告
    20201105-1 每周例行报告
    作业要求 20201029-1 每周例行报告
    作业要求 20201022-1 每周例行报告
  • 原文地址:https://www.cnblogs.com/brucemengbm/p/7360337.html
Copyright © 2011-2022 走看看