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新建项目 ...
随机推荐
- Asp.Net 遍历 循环 显示所有COOKIS,SESSION,Applocation
在C#中循环显示SESSIOn: Response.Write("<br>Session的所有值:<br>"); foreach (string obj i ...
- Codeforces Round #527 (Div. 3)D2(栈,思维)
#include<bits/stdc++.h>using namespace std;int a[200007];stack<int>s;int main(){ int ...
- kylin cube 构建过程
本文是对 http://kylin.apache.org/docs20/howto/howto_optimize_build.html的翻译,以便阅读. 1. 创建 Hive 中间表(Create ...
- Android OpenGLES2.0(十七)——球形天空盒VR效果实现
在3D游戏中通常都会用到天空盒,在3D引擎中也一般会存在天空盒组件,让开发者可以直接使用.那么天空盒是什么?天空盒又是如何实现的呢?本篇博客主要介绍如何在Android中利用OpenGLES绘制一个天 ...
- Jmeter_拦截Excel文件输出流到本地
一般而言,对于页面的“导出”操作,主要经历如下两个操作:①根据数据库的内容,将文件导出到应用服务器上:②将服务器上的文件下载到本地电脑: Jmeter同LoadRunner类似,只能记录服务端与客户端 ...
- Luogu P1768 天路 0/1分数规划+dfs spfa
“那是一条神奇的天路诶~~把第一个神犇送上天堂” 怕不是某大佬早就A了这题,然鹅我又调了很久很久... 好吧就是0/1分数规划,但是跑的dfs的spfa(好像题解说bfs过不了????不知) 发现把s ...
- 1105 Spiral Matrix(25 分)
This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasi ...
- Linux之dstat命令
dstat命令是一个用来替换vmstat.iostat.netstat.nfsstat和ifstat这些命令的工具,是一个全能系统信息统计工具.与sysstat相比,dstat拥有一个彩色的界面,在手 ...
- MYSQL性能优化之Mysql数据库监控
监控对象 数据库可用性监控数据库进程或是端口存在并不意味着数据库就是可用的 也就是说登陆服务器,并且能正确执行mysql命令 数据库性能 QPS和DPS并发线程数量(同时执行sql语句的数量,不是连接 ...
- GUI的最终选择 Tkinter(一):Tkinter最初体验
EasyGui就是一个简单的文字交互界面模块,从今天开始来开始学习Tkinter Tkinter是Python标准的Gui库,它实际是建立在Tk技术上的,Tk最初是为Tcl(一门工具名语言)所涉及的, ...