一   自定义push方法

/*  参数说明

*  controllerName : push的目标页 例:@“testcontroll”    ---注意不带.h

*  isNibPage     : 目标页是否带 xib 文件

*  setHideTabBar : 当前页是否隐藏 tabBar      -----注意 是当前页 非目标页

*  setDelegate   : 设置委托

*/

- (void)pushNewViewController:(NSString *)controllerName isNibPage:(BOOL) _isNib setHideTabBar:(BOOL) _bool setDelegate:(BOOL) _setdelegate{

if (controllerName.length <= 0) {

return;

}

Class   class_Page = NSClassFromString((NSString *)controllerName);

id viewCtrl_Page = _isNib ? [[class_Page alloc] initWithNibName:controllerName bundle:nil]

: [[class_Page alloc] init];

if (_setdelegate) { [viewCtrl_Page setDelegate:self]; }

if (!m_Params)    { m_Params = [[NSMutableDictionaryalloc]init]; }

[m_Params setValue:_bool == YES ? @"1" : @"0" forKey:@"HideTabBar"];

[viewCtrl_Page setM_Params:[m_Params retain]];

if (isLoginPage) {

if ([GlobalisUserLogin]) {

[self.navigationControllerpushViewController:viewCtrl_Page animated:YES];

}

else{

[selfshowLoginController];

}

}

else

[self.navigationControllerpushViewController:viewCtrl_Page animated:YES];

[viewCtrl_Page release];

if (m_Params) {

[m_Params release];

}

}

二       根据TableView里的button获取父级UITableViewCell

1.   通过对像的父级查找

UIButton *btn_checkBox = (UIButton *)sender;

UITableViewCell * cell = (UITableViewCell *)[btn_checkBox superview];

NSIndexPath* indexPath = [m_tableViewindexPathForCell:cell];

2.   通过点击座标

// 检查用户点击按钮时的位置,并转发事件到对应的accessory tapped事件
- (void)btnClicked:(id)sender event:(id)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:currentTouchPosition];
if(indexPath != nil)
{
[self tableView:self.tableView accessoryButtonTappedForRowWithIndexPath:indexPath];
}
}

三  常常要算一段文字的长度和高度。下面这段代码可以帮到你

CGSize  fontsize = [tmpCoupon.couponDescsizeWithFont:[UIFontboldSystemFontOfSize:13] constrainedToSize:CGSizeMake(162, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];

  // 计算文本的大小  ios7.0

CGSize textSize = [textViewTemple.text boundingRectWithSize:CGSizeMake(self.imagewidth, MAXFLOAT)                                                         options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading // 文本绘制时的附加选项

attributes:dic  context:nil].size;

四  文本编辑的时候键盘档住页面,下面代码自动收缩

- (void)textFieldDidBeginEditing:(UITextField *)textField{

  CGRect frame = textField.frame;

  int offset = frame.origin.y + 32 - (self.view.frame.size.height - 216.0-10);

  NSTimeInterval animationDuration = 0.30f;

     [UIView beginAnimations:@"ResizeForKeyBoard" context:nil];

[UIView setAnimationDuration:animationDuration];
float width = self.view.frame.size.width;
float height = self.view.frame.size.height;
if(offset > 0){
CGRect rect = CGRectMake(0.0f, -offset,width,height);
self.view.frame = rect;
}
[UIView commitAnimations];

}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
NSTimeInterval animationDuration = 0.30f;
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:animationDuration];
CGRect rect = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, self.view.frame.size.height);
self.view.frame = rect;
[UIView commitAnimations];

[textField resignFirstResponder];
return YES;

// 十六进制设置alpha值

+ (UIColor *)convertHexToRGB:(NSString *)hexString alpha:(CGFloat)alpha {

NSString *str;

if ([hexString hasPrefix:@"0x"] || [hexString hasPrefix:@"0X"]) {

str=[[NSString alloc] initWithFormat:@"%@",hexString];

}else {

str=[[NSString alloc] initWithFormat:@"0x%@",hexString];

}

int rgb;

sscanf([str cStringUsingEncoding:NSUTF8StringEncoding], "%i", &rgb);

[str release];

int red=rgb/(256*256)%256;

int green=rgb/256%256;

int blue=rgb%256;

UIColor *color=[UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:alpha];

return color;

}

五  .  数组排序

NSSortDescriptor * sortDescriptor = [[NSSortDescriptoralloc] initWithKey:@"createTime"ascending:NO];

[arrMsgListsortUsingDescriptors:[NSArrayarrayWithObject:sortDescriptor]];

iOS 开发小常识 开发笔记的更多相关文章

  1. iOS AVCaptureSession 小视频开发总结,支持设备旋转

    iOS开发中当我们想要自定义相机拍照或摄像界面时,UIImagePickerController无法满足我们的需求,这时候我们可以使用AVFoundation.framework这个framework ...

  2. Java 开发小常识

    从理论上来讲Java做的系统并不比其他语言开发出来的系统更占用内存,那么为什么却有这么多理由来证明它确实占内存呢?两个字,陋习. 1.别用new Boolean().在很多场景中Boolean类型是必 ...

  3. 微信小程序开发详解——小程序,大颠覆!

    微信小程序开发 联系 苏念 188.1414.7927  微信小程序系统开发 微信新功能开发 小程序开发 小程序怎么开发 app小程序开发 简化小程序开发 微信小程序定制 小程序制作 开发微信小程序  ...

  4. iOS开发小技巧 - UILabel添加中划线

    iOS开发小技巧 遇到的问题: 给Label添加中划线,然后并没有效果 NSString *str = [NSString stringWithFormat:@"合计金额 ¥%.2f&quo ...

  5. iOS开发小技巧 - runtime适配字体

    iOS开发小技巧 - runtime适配字体 版权声明:本文为博主原创文章,未经博主允许不得转载,有问题可联系博主Email: liuyongjiesail@icloud.com 一个iOS开发项目无 ...

  6. iOS学小程序从0到发布(适合iOS开发看)

    Emmmm,最近一波失业潮.富某康.某团.摩某.京某.知某.某浪.58 某大面积裁员,那么在这个千钧一发之际,单纯iOS开发也着实不好过,回过头看一下,裁掉的都是单一选手,为了节约成本公司留下的都是身 ...

  7. 微信小程序开发:学习笔记[7]——理解小程序的宿主环境

    微信小程序开发:学习笔记[7]——理解小程序的宿主环境 渲染层与逻辑层 小程序的运行环境分成渲染层和逻辑层. 程序构造器

  8. 微信小程序开发:学习笔记[5]——JavaScript脚本

    微信小程序开发:学习笔记[5]——JavaScript脚本 快速开始 介绍 小程序的主要开发语言是 JavaScript ,开发者使用 JavaScript 来开发业务逻辑以及调用小程序的 API 来 ...

  9. 微信小程序开发:学习笔记[4]——样式布局

    微信小程序开发:学习笔记[4]——样式布局 Flex布局 新的布局方式 在小程序开发中,我们需要考虑各种尺寸终端设备上的适配.在传统网页开发,我们用的是盒模型,通过display:inline | b ...

随机推荐

  1. 2019天梯赛练习题(L1专项练习)

    7-1 水仙花数 (20 分) 水仙花数是指一个N位正整数(N≥3),它的每个位上的数字的N次幂之和等于它本身.例如:1. 本题要求编写程序,计算所有N位水仙花数. 输入样例: 3 输出样例: 153 ...

  2. [模板] 动态ST表

    ST表本身是不可修改的. 如果考虑增加一个数,可以把ST表反过来写,即f[i][j]表示i往前1<<j个数,一个数最多影响logn个数,常数非常小. #include<iostrea ...

  3. (2) OpenSSL命令

    openssl命令的格式是"openssl command command-options args",command部分有很多种命令,这些命令需要依赖于openssl命令才能执行 ...

  4. bash实现自动补全

    yum install -y bash-completion source /usr/share/bash-completion/bash_completion 执行后yum拥有选项自动补全功能 对于 ...

  5. Django框架基础知识09-请求与响应

    视图函数接受到的request到底是个什么对象呢? HttpRequest对象: 服务器接收到http协议的请求后,会根据报文创建HttpRequest对象视图函数的第一个参数是HttpRequest ...

  6. POJ 3310 Caterpillar(图的度的判定)

    题意: 给定一幅图, 问符不符合一下两个条件: (1) 图中没有环 (2)图中存在一条链, 点要么在链上, 要么是链上点的邻居. 分析: 建图,记录度数, 去掉所有度为1的点, 然后看看剩下是否是有2 ...

  7. 算法导论 第一章and第二章(python)

    算法导论 第一章 算法     输入--(算法)-->输出   解决的问题     识别DNA(排序,最长公共子序列,) # 确定一部分用法     互联网快速访问索引     电子商务(数值算 ...

  8. 一些简单的JavaScript的方法

    <script type="text/javascript"> //js跳转 function UserMouserDown() { confirm('你确定要删除吗? ...

  9. notepad++编辑器写python需注意使用utf-8编码

    语言:python3.4 文本编辑器:notepad++ 报错:SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xb4 in ...

  10. BNU 4346 Scout YYF I

    A. Scout YYF I Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java cla ...