美文网首页
ios问题整理

ios问题整理

作者: 维Fatal | 来源:发表于2017-02-09 10:38 被阅读0次

    Xcode中将图片放到images.xcassets中的好处

    1.如果图片是被放到images.xcassets中(部署版本>=ios8),之后打包的资源包中的图片会被放到Assets.car中,图片有被压缩. 如果部署版本

    2.如果图片不被放到images.xcassets中,即直接拖拽到项目当中,无论部署版本是多少,都会被放到MainBundle中。这样图片没有被压缩。

    所以说在部署版本8.0以后,将图片放到images.xcassets中是很有必要的,因为这样可以让我们的打包程序变得不再像之前那么大。

    切记!!!

    set object key与 setValue key区别

    1, setObject:forkey:中value是不能够为nil的,不然会报错。setValue:forKey:中value能够为nil,但是当value为nil的时候,会自动调用removeObject:forKey方法

    2, setValue:forKey:中key的参数只能够是NSString类型,而setObject:forKey:的可以是任何类型

    注意:setObject:forKey:对象不能存放nil要与下面的这种情况区分:1, [imageDictionarysetObject:[NSNullnull]forKey:indexNumber];[NSNull null]表示的是一个空对象,并不是nil,注意这点

    2, setObject:forKey:中Key是NSNumber对象的时候,如下:[imageDictionarysetObject:objforKey:[NSNumber numberWithInt:10]];

    注意:

    上面说的区别是针对调用者是dictionary而言的。setObject:forKey:方法NSMutabledictionary特有的,而setValue:forKey:方法是KVC(键-值编码)的主要方法。当setValue:forKey:方法调用者是对象的时候:setValue:forKey:方法是在NSObject对象中创建的,也就是说所有的oc对象都有这个方法,所以可以用于任何类。

    比如使用:SomeClass *someObj = [[SomeClass alloc] init];[someObj setValue:self forKey:@"delegate"];表示的意思是:对象someObj设置他的delegate属性的值为当前类,当然调用此方法的对象必须要有delegate属性才能设置,不然调用了也没效果

    3.图文按钮设置

    http://blog.csdn.net/lqq200912408/article/details/51323336

    http://www.jianshu.com/p/3052a3b14a4e

    4.搜索框设置

    //搜索框

    CGRectmainViewBounds =self.navigationController.view.bounds;

    UISearchBar*customSearchBar = [[UISearchBaralloc]initWithFrame:CGRectMake(CGRectGetWidth(mainViewBounds) /2- ((CGRectGetWidth(mainViewBounds) -88) /2),CGRectGetMinY(mainViewBounds) +22,CGRectGetWidth(mainViewBounds) -88,40)];

    customSearchBar.delegate=self;

    customSearchBar.showsCancelButton=NO;

    customSearchBar.searchBarStyle=UISearchBarStyleMinimal;

    customSearchBar.placeholder=@"输入试题名称或者关键字";

    [self.navigationController.view addSubview: customSearchBar];

    UITextField*searchField = [customSearchBarvalueForKey:@"searchField"];

    if(searchField) {

    [searchFieldsetBackgroundColor:DefaultColor];

    searchField.layer.cornerRadius=14.0f;

    searchField.layer.borderColor= [UIColorwhiteColor].CGColor;

    searchField.layer.borderWidth=0.5;

    searchField.layer.masksToBounds=YES;

    [searchFieldsetValue:[UIColorwhiteColor]forKeyPath:@"_placeholderLabel.textColor"];

    }

    // searchBar图标设置

    [customSearchBarsetImage:[UIImageimageNamed:@"ic_research"]forSearchBarIcon:UISearchBarIconSearchstate:UIControlStateNormal];

    相关文章

      网友评论

          本文标题:ios问题整理

          本文链接:https://www.haomeiwen.com/subject/okriittx.html