iphone开发笔记
1.uiimage图片拉伸
- (void)stretchBackgroundImage
{
//UIImage *originalImage = [[self backgroundImageForState:UIControlStateNormal] copy];
UIImage *originalImage = [UIImage imageNamed:@"sure_publish_green.png"];
//UIEdgeInsets insets = UIEdgeInsetsMake(2, 10, 2, 10);
//UIImage *stretchableImage = [originalImage resizableImageWithCapInsets:insets];
UIImage *stretchableImage = [originalImage stretchableImageWithLeftCapWidth: topCapHeight:];
[self setBackgroundImage:stretchableImage forState:UIControlStateNormal];
}
2.willmovetosupreview
http://iloss.me/blog/2013/05/28/ios6-willmovetosuperview/
3.size to fit 快捷键 cmd + =
4.nsstring to nsdate
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [dateFormatter dateFromString:publicationDate ];
[dateFormatter release];
5.reloaddata scrollto
- (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[theTableView deselectRowAtIndexPath:indexPath animated:NO];
if (itemType == ItemTypeMore) //更多选项
{
[theTableView reloadData];
[theTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
}
6.uiview animation
[UIView animateWithDuration:0.3 animations:^{
edit.frame = editFrame;
}];
7./BaiduMobStat/lib/Release$(EFFECTIVE_PLATFORM_NAME)
EFFECTIVE_PLATFORM_NAME 识别真机iphoneos 模拟器 iphonesimulator
Release-iphoneos
Release-iphonesimulator
8.objective-c语法糖 http://blog.devtang.com/blog/2012/08/05/use-modern-objective-c/
9.ARC和非ARC混编
在非ARC环境下,如果想对某个文件单独进行ARC处理,则在Build Parses里的.m文件后加-fobjc-arc,反之则加-fno-objc-arc
10.图片压缩http://www.open-open.com/lib/view/open1375933073921.html
11.cell取消选中状态[tableView deselectRowAtIndexPath:indexPath animated:YES];
12.cell不能选中cell.selectionStyle = UITableViewCellSelectionStyleNone 创建cell的时候设置这个
13.圆角设置
m_mainImgView.layer.cornerRadius = 6;
m_mainImgView.layer.masksToBounds = YES;
14.demo学习http://www.ioslearner.com/uiappearance-proxy-protocol-tutorial/
15.navigationBar add searchBar
To put searchBar into the center of navigationBar:
self.navigationItem.titleView = self.searchBarTop;
-------
To put searchBar to the left/right side of navigationBar:
UIBarButtonItem *searchBarItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar];
self.navigationItem.rightBarButtonItem = searchBarItem;
16.((UILabel*)[[testAlert subviews] objectAtIndex:1]).textAlignment =UITextAlignmentLeft; UIAlertView 居中
17.http://webfrogs.me/2013/04/22/build-cocoapods-project/ CocoaPods 第三方类库管理学习
18.mutiple line text of uilabel http://stackoverflow.com/questions/990221/multiple-lines-of-text-in-uilabel
found a solution.
One just has to add the following code:
textLabel.lineBreakMode =NSLineBreakByWordWrapping;
textLabel.numberOfLines =0;
Restored old answer (for reference and devs willing to support iOS below 6.0):
textLabel.lineBreakMode =UILineBreakModeWordWrap;
textLabel.numberOfLines =0;
19.label 关键字标记成红色
NSString *text = @"其实没什么";
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:text];
[attributeString setAttributes:@{NSForegroundColorAttributeName : [UIColor redColor], NSFontAttributeName : [UIFont systemFontOfSize:]} range:NSMakeRange(, )];
myLabel.attributedText = attributeString;
20.UIButton上image和title的位置调整方法:
//UIEdgeInsetsMake(top left bottom right)
[button setImageEdgeInsets:UIEdgeInsetsMake(0.0, 100.0, 0.0, 0.0)]; //将image的位置向右移动100个像素 [button setTitleEdgeInsets:UIEdgeInsetsMake(0.0 , 100.0, 0.0 , 0.0)]; ////将title的位置向右移动100个像素 //UIEdgeInsetsMake原型
UIKIT_STATIC_INLINE UIEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) {
UIEdgeInsets insets = {top, left, bottom, right};
return insets;
}
21.http://www.cocoachina.com/applenews/devnews/2013/0827/6876.html
22.转义% %%
23.隐藏系统状态栏 让app启动时图片全屏 进入程序后显示状态栏方法。
1)在<APP>-info.list文件中,加上“Status bar is initially hidden”选项,选择yes
2)在程序里面添加 [[UIApplication sharedApplication]setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
即可
24.CGFloat fontHeight = [@"string" sizeWithFont:[UIFont fontWithName:@"HelveticaNeue" size:15.0f]].height; 取字体高度
25.xcode正则替换
@synthesize\s(\w+)
copy.\1 = [\1 copyWithZone:zone]
26.label多行left-top对齐
CGRect frame = cell.contentLabel.frame;
cell.contentLabel.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, );
cell.contentLabel.lineBreakMode = NSLineBreakByWordWrapping;
cell.contentLabel.numberOfLines = ;
cell.contentLabel.text = @"李先生李先生李先生李先生李先生李先生李先生李先生";
[cell.contentLabelsizeToFit];
27.通过UITableViewCell获得cell在table中信息
UITableView* table = (UITableView *)[cell superview];
NSIndexPath* pathOfTheCell = [table indexPathForCell:cell];
NSInteger sectionOfTheCell = [pathOfTheCell section];
NSInteger rowOfTheCell = [pathOfTheCell row];
28.顺序动画执行
[UIView animateWithDuration:0.7 //速度0.7秒
animations:^{//修改rView坐标
//animate 1
}
completion:^(BOOL finished){
[UIView animateWithDuration:0.7 //速度0.7秒
animations:^{//修改rView坐标
//animate 2
}
completion:^(BOOL finished){ }];
}];
29.让UIButton中图片位置偏移
[myButton setImage: [UIImage imageNamed:@"settingImage.png"] forState:UIControlStateNormal];
[myButton setImageEdgeInsets:UIEdgeInsetsMake(0.0, 100.0, 0.0, 0.0)]; //将image的位置向右移动100个像素
30.格式化输出时间
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:kCFDateFormatterShortStyle];
[formatter setTimeStyle:kCFDateFormatterShortStyle];
formatter.dateFormat = @"HH:mm a";
NSLog(@"date : %@", [formatter stringFromDate:date]);
30.点击UIButton缩小动画
// Scale up on button press
- (void) buttonPress:(UIButton*)button {
button.transform = CGAffineTransformMakeScale(1.1, 1.1);
// Do something else
} // Scale down on button release
- (void) buttonRelease:(UIButton*)button {
button.transform = CGAffineTransformMakeScale(1.0, 1.0);
// Do something else
} [btn addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchDown];
[btn addTarget:self action:@selector(buttonRelease:) forControlEvents:UIControlEventTouchUpInside];
[btn addTarget:self action:@selector(buttonRelease:) forControlEvents:UIControlEventTouchUpOutside];
[btn addTarget:self action:@selector(buttonRelease:) forControlEvents:UIControlEventTouchCancel];
[btn addTarget:self action:@selector(buttonRelease:) forControlEvents:UIControlEventTouchDragExit];
31.删除tableviewcell时,应该先删除数据源里的数据后,再用deleteRowsAtIndexPaths删除tableview的行
for (int i = ; i < count; i++)
{
IHaveSeenCarInfoItem *deleteObject = [deleteObjectArray objectAtIndex:i];
int deleteDbId = deleteObject.carInfo.dbId; CarDetailInfoDao *carDao = [CarDetailInfoDao sharedCarDetailInfoDao];
if (curSelectFilter_ == IHaveSeenFilterTypeCollect)
{
[carDao deleteCollectRecord:deleteDbId];
}
else if (curSelectFilter_ == IHaveSeenFilterTypeContactRecord)
{
[carDao deleteContactRecord:deleteDbId];
}
else if (curSelectFilter_ == IHaveSeenFilterTypeBrowseRecord)
{
[carDao deleteBrowseRecord:deleteDbId];
} [carInfoArray removeObject:deleteObject];
} [self.carInfoTableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
32.图片压缩
NSData *imageData = UIImageJPEGRepresentation(image, 0.5);//压缩比例
33.前50条记录
- (NSMutableArray *)getRecordArray:(CarDetailInfoType)type
{
NSMutableArray *recordArray = [[NSMutableArray alloc] init];
NSString *tableName = tableNameArray_[type];
FMDatabase *db = [DBUtils openDB]; NSString *sql = [[NSString alloc] initWithFormat:@"SELECT * FROM %@ ORDER BY db_id DESC LIMIT 50", tableName];
FMResultSet *rs = [db executeQuery:sql];
while ([rs next])
{
CarDetailInfo *carDetailInfo = [[CarDetailInfo alloc] init]; carDetailInfo.dbId = [rs intForColumn:@"db_id"]; [recordArray addObject:carDetailInfo];
} return recordArray;
}
34.~/Library/MobileDevice/Provisioning Profiles xcode5证书目录
iphone开发笔记的更多相关文章
- iphone开发笔记目录
http://www.cnblogs.com/syxchina/archive/2012/10/20/2732731.html#2653802
- iPhone开发笔记(20)EGOImageView的使用方法及注意事项
EGOImageView是一种实现网络图片的异步加载和缓存的第三方类库,具有相同功能的第三方类库还有SDWebImage.但是相比两个类库的安装和使用来说,EGOImageView更简单一些,下面就介 ...
- 智能手机Web开发笔记
智能手机版(简称M版)前端开发终于告一段落,第一次做移动端开发,没有想象中那么难搞,但是期间也遇到了各种这样那样的问题,虽然从小日记都不是自己写的,但是开发笔记还是要自己写的,不敢说让别人学习,只是仅 ...
- iBeacon 开发笔记
iBeacon开发笔记 2015.10.19 airlocate ========= airlocate显示如何使用这个监控范围clbeaconregions. 代码还提供了一个例子,你如何能校准和配 ...
- 【Swift】iOS开发笔记(二)
前言 这个系列主要是一些开发中遇到的坑记录分享,有助于初学者跨过这些坑,攒够 7 条发一篇. 声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnblogs.com 农民伯 ...
- 菜鸟手下的iOS开发笔记(swift)
在阳春4月的一天晨会上,有一个老板和蔼的对他的一个菜鸟手下说:“你既然会Android,那你能不能开发iOS?” 不是说好的要外包的吗?内心跌宕,但是表面淡定的菜鸟手下弱弱的回道:“可以试试”. 第二 ...
- iPhone开发与cocos2d 经验谈
转CSDN jilongliang : 首先,对于一个完全没有mac开发经验,甚至从没摸过苹果系统的开发人员来说,首先就是要熟悉apple的那一套开发框架(含开发环境IDE.开发框架uikit,还有开 ...
- iOS开发UI篇—iPad和iPhone开发的比较
一.iPad简介 1.什么是iPad 一款苹果公司于2010年发布的平板电脑 定位介于苹果的智能手机iPhone和笔记本电脑产品之间 跟iPhone一样,搭载的是iOS操作系统 2.iPad的市场情况 ...
- [开发笔记]-未找到与约束ContractName Microsoft.VisualStudio.Text.ITextDocumentFactoryService...匹配的导出【转载自:酷小孩】
原文地址:http://www.cnblogs.com/babycool/p/3199158.html 今天打算用VisualStudio2012做一个js效果页面测试的时候,打开VS2012新建项目 ...
随机推荐
- 大数据实习之spark
Apache Spark是一个围绕速度.易用性和复杂分析构建的大数据处理框架. 与 Hadoop 和 Storm 等其他大数据和 MapReduce 技术相比,Spark 有如下优势. 首先,Spar ...
- 浅谈js模块加载方式(初级)
1.简介: 前端模块化开发日渐鼎盛,如何将零散的插件或者是普通的js脚本文件统一管理及引用,是众多开发者共同的目标.本人是从事.net开发的,最近对前端的一些东西特别的感兴趣,也会尝试的夹杂一点自己 ...
- 聊聊 CDN 缓存与浏览器缓存
CDN 是互联网上内容分发的重要一环.无论您之前是否了解过 CDN,其实它已经在您的日常生活中发挥作用了.比如您正在淘宝挑选心仪的商品,或者在观看一段令人捧腹的视频,以及您正在阅读的这篇文章,这些资源 ...
- Collectd+InfluxDB+Grafana监控系统搭建
环境配置 节点 配置 类型 操作系统 Sched 2G 2CPU 50GB ens3=>192.168.200.11 KVM虚拟机 CentOS 7 Nova 4G 2CPU 50GB ens3 ...
- GXU - 7D - 区间求和 - 前缀和
https://oj.gxu.edu.cn/contest/7/problem/D 描述 有一个所有元素皆为0的数组A,有两种操作: 1 l r x表示将A区间[l,r]内所有数加上x: 2 l r表 ...
- 2018上海大都会邀请赛J(数位DP)
#include<bits/stdc++.h>using namespace std;int num[20];//按位储存数字int mod;long long dp[20][110][1 ...
- Unity3D -- shader光照常用函数和变量
上一篇记录了shader常用函数和变量,这篇记录一些光照计算时常用函数和变量 1.内置的光照变量 _LightColor0 float4 //该Pass处理的逐像素光源的颜色 _WorldSpaceL ...
- cf837D(01背包)
题目链接: http://codeforces.com/contest/837/problem/D 题意: 给出 n 个数, 从中选出 k 个数使得这 k 个数的乘积末尾 0 最多 . 思路: 先记录 ...
- bzoj4514: [Sdoi2016]数字配对(费用流)
传送门 ps:费用流增广的时候费用和流量打反了……调了一个多小时 每个数只能参与一次配对,那么这就是一个匹配嘛 我们先把每个数分解质因数,记质因子总个数为$cnt_i$,那如果$a_i/a_j$是质数 ...
- SLF4J、Log4J使用记录
程序中一直在用log4j,之前都没了解过,只知道是打印日志信息的.最近独立新建了几个开发工程,发现slf4j老有冲突,开始关注起来,我用log4j打印日志,与slf4j有毛关系,怎么老冲突呢.网上找了 ...