mark! 细节整理,记录问题

判断字符串是否是合法的邮箱地址
-(BOOL) NSStringIsValidEmail:(NSString *)checkString
{
   BOOL stricterFilter = YES; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/
   NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}";
   NSString *laxString = @".+@([A-Za-z0-9]+\\.)+[A-Za-z]{2}[A-Za-z]*";
   NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
   NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
   return [emailTest evaluateWithObject:checkString];
}

计算两个日期之间相差几天几小时几分钟
用timeIntervalSinceDate得到日期之间相差的秒数,然后再转换成天数小时和分
    
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
   
    NSDateComponents *comps = [[NSDateComponents alloc] init];
    NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit |
    NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
     comps=[calendar components:unitFlags fromDate:date toDate:date options:0];
    NSLog(@"%@",comps);
   // comps = [calendar components:unitFlags fromDate:date];


NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
   [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
   NSDate *  senddate=[NSDate date];
   //结束时间
   NSDate *endDate = [dateFormatter dateFromString:@"2014-6-24 00:00:00"];
   //当前时间
   NSDate *senderDate = [dateFormatter dateFromString:[dateFormatter stringFromDate:senddate]];
   //得到相差秒数
   NSTimeInterval time=[endDate timeIntervalSinceDate:senderDate];
    
   int days = ((int)time)/(3600*24);
   int hours = ((int)time)%(3600*24)/3600;
   int minute = ((int)time)%(3600*24)600/60;
   
   if (days <= 0&&hours; <= 0&&minute; <= 0)
       dateContent=@"0天0小时0分钟";
   else
       dateContent=[[NSString alloc] initWithFormat:@"%i天%i小时%i分钟",days,hours,minute];

刷新某行cell的方法

NSIndexPath *indexPath_1=[NSIndexPath indexPathForRow:indePath.row inSection:0];
      NSArray *indexArray=[NSArray  arrayWithObject:indexPath_1];
      [myTableView  reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationAutomatic];

iOS7上tableView的分割线左边短了一点

ios7里面tableViewCell上面的分割线,左边少了20个像素,用下面的方法,可以让分割线完整显示出来
if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
           [_tableView setSeparatorInset:UIEdgeInsetsZero];
       }

改变状态栏字体颜色

1.在info.plist里面添加字段
key----View controller-based status bar appearance
value---NO
 
在appDelegate里面添加代码:
 [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
 
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];

如何让textField输入框 限制输入字数的同时,还只让输入数字和字母

//UITextFieldDelegate  
- (BOOL)textFieldShouldReturn:(UITextField *)textField;  
{  
    //用户结束输入  
    [textField   resignFirstResponder];  
   
    return  YES;  
}  
 
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string   // return NO to not change text  
{  
    //判断是否超过 ACCOUNT_MAX_CHARS  个字符,注意要判断当string.leng>0  
    //的情况才行,如果是删除的时候,string.length==0  
    int length = textField.text.length;  
    if (length >= ACCOUNT_MAX_CHARS  &&  string.length >0)  
    {  
        return  NO;  
    }  
       
       
    NSCharacterSet *cs;  
    cs = [[NSCharacterSet characterSetWithCharactersInString:kAlphaNum] invertedSet];  
    NSString *filtered =  
    [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];  
    BOOL basic = [string isEqualToString:filtered];  
    return basic;  
}

企业版ipa安装方法

访问my.html,通过itms-services协议跳转到my.plist实现下载安装my.ipa 
相关my.ipa设置需修改my.plist文件

/*网页部分 "my.html"*/
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >
<html>
  <head>
    <title>安装我的应用</title>
  </head>
  <body>
    <a href='itms-services://?action=download-manifest&url=http://192.168.1.123:8080/ipa.plist'>安装我的应用</a>
  </body>
</html>
/*plist文件部分 my.plist*/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>items</key>
   <array>
       <dict>
           <key>assets</key>
           <array>
               <dict>
                   <key>kind</key>
                   <string>software-package</string>
                   <key>url</key>
                   <string>http://192.168.1.123:8080/ipa/my.ipa</string>
               </dict>
               <dict>
                   <key>kind</key>
                   <string>display-image</string>
                   <key>needs-shine</key>
                   <true/>
                   <key>url</key>
                   <string>http://192.168.1.123/ipa/icon_120.png</string>
               </dict>
        <dict>
                   <key>kind</key>
                   <string>full-size-image</string>
                   <key>needs-shine</key>
                   <true/>
                   <key>url</key>
     <string>http://192.168.1.123:8080/ipa/icon_120.png</string>
               </dict>
           </array><key>metadata</key>
           <dict>
               <key>bundle-identifier</key>
               <string>com.my.myapp</string>
               <key>bundle-version</key>
               <string>1.0.0</string>
               <key>kind</key>
               <string>software</string>
               <key>subtitle</key>
               <string>我的应用</string>
               <key>title</key>
               <string>我的应用</string>
           </dict>
       </dict>
   </array>
</dict>
</plist>










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值