zoukankan      html  css  js  c++  java
  • iOS 犄角旮旯的知识

    1、全局变量

    static NSInteger kImageHeight = 300;

    #define kImageHeight 300

    2、通知中心

    开始编辑

    UITextViewTextDidBeginEditingNotification 

    正在更改

    UITextViewTextDidChangeNotification

    结束编译

    UITextViewTextDidEndEditingNotification

    //注册文字改变通知

            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChangeNotifition:) name:UITextViewTextDidChangeNotification object:nil];

    - (void)dealloc

    {

        [[NSNotificationCenter defaultCenter] removeObserver:self name:UITextViewTextDidChangeNotification object:nil];

    }

    3、动态加载(不用导入头文件)

     

    NSArray * vcNames1 = @[@"FriendViewController"];

    NSArray * vcNames2 = @[@"SwipeViewController",@"SharkViewController"];

    self.viewControllers = @[vcNames1,vcNames2];

    NSString * vcName = self.viewControllers[indexPath.section][indexPath.row];

    UIViewController * vc = [[NSClassFromString(vcName) alloc] init];

    例如:自定义Button类:UIButton

    在viewController 声称对应button对象 进行重写init方法来定义 类型

    不能在button类中写button属性 因为在懒加载中 添加点击事件 调不到

    4、更改图片颜色; 忽略它的颜色信息

    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

    5、项目结构

    6、 当导航视图控制器压栈时,隐藏tabbar

        vc.hidesBottomBarWhenPushed = YES;

    7、图片加边框,代码:

    imageLayer.borderColor = [UIColor grayColor].CGColor;  //边框颜色
    imageLayer.borderWidth = 2.0;  //边框宽度
    8、磊神教学Block

    (1)声明block变量并设置返回值类型

    typedef NSString *(^MYBlock)(NSString *);

    @property (nonatomic, copy) MYBlock block;

    (2)调用Block方法(发送),并接收返回值

    NSString * string = self.block(@"123);

    NSLog(@“%@“,string);

    (3)调用Block方法(接收),并接收返回值

    self.ceshi.block =  ^ (NSString *string) {

    NSLog(@"%@",string);

    return@“peng";

    };

    (4)利用typedef定义block类型(和指向函数的指针很像)

    (类)Typedef int(^MyBlock)(int ,int);

    以后就可以利用这种类型来定义block变量了。

    (类)MyBlock block1,block2;  

    (类)int i = block1(3,4);

    (主)block1=^(int a,int b){

    return a-b;

    };

    __weak ViewController *mySelf = self; block中避免循环引用

  • 相关阅读:
    网上Silverlight项目收集
    在Silverlight页面里显示HTML的免费控件下载(附使用方法代码)
    Silverlight SNS项目
    Visual Studio 2010下的RIA开发,Silverlight 4线下技术交流会期待您的参与!
    Windows7硬件展示与客户端信息收集
    Silverlight版的神奇罗盘,仿Google的Flash神奇罗盘
    (解题思路)Entity Framework 如动态创建表或者列
    (学)这些年来的几宗罪
    (学)在SQL2005中使用分区表技术
    (医)有痔青年的福音
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5272071.html
Copyright © 2011-2022 走看看