一   自定义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]];

最新文章

  1. 基础知识《十》unchecked异常和checked异常
  2. Java开发的基础条件:
  3. PopupWindow事件分发冲突解决
  4. mybatis 中#和$的区别
  5. R语言--数据预处理
  6. 初学Node(五)文件I/O
  7. MongoDB学习笔记——文档操作之查询
  8. 配置个舒心的 Java 开发环境
  9. IOS 从系统图库中获取 图片 并设置为头像
  10. Chrome 将默认不播放非重要 Flash 内容
  11. 【转】MAT(Memory Analyzer Tool)工具入门介绍
  12. 201521123036 《Java程序设计》第8周学习总结
  13. nodejs 初次链接 mongodb 的详细细节
  14. javaweb学习总结(五)——Servlet开发(一)(转)
  15. CentOS 7.0 启动多个MySQL实例(mysql-5.7.21)
  16. spring javaconfig druidsource
  17. Windows下安装ZooKeeper
  18. 首先看一下友晶DE-SOC开发板的user manual
  19. maven阿里云镜像
  20. Android Studio 小新兵

热门文章

  1. http请求响应格式
  2. 洛谷 P3131 子共七
  3. Melancholy(磨懒虫主义)
  4. ArrayList集合(JDK1.8)
  5. linux 部署nginx作为反向代理入口的内核参数/etc/sysctl.conf
  6. 分享下找到的Github上大神的EmpireofCode进攻策略:反正我是用了没反应,改了代码后单位不进攻,蠢站在那里,我自己的策略调调能打败不少人,这个日后慢慢研究吧,Github上暂时找到的唯一策略
  7. jquery ajax示例
  8. java基础之switch
  9. 用python写自定义模板
  10. python接口自动化-token参数关联登录(登录拉勾网)