mark! 問題を細かく整理する

6838 ワード

文字列が正当なメールアドレスかどうかを判断する
-(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];
}
2 2つの日付の間に数日数時間数分の差があることを計算します
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];

iOS 7上tableViewの分割線左が少し短くなっています
ios 7では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>