iOS 작업 중 발생 하 는 문제 (1)

              
http://www.jianshu.com/p/de718ef3bd20
//    view      
- (UIViewController *)viewController {
  UIViewController *viewController = nil;
  UIResponder *next = self.nextResponder;
  while (next) {
    if ([next isKindOfClass:[UIViewController class]]) {
      viewController = (UIViewController *)next;
      break;
    }
    next = next.nextResponder;
  }
  return viewController;
}
   UIImage      
- (UIImage *) imageWithBackgroundColor:(UIColor *)bgColor

shadeAlpha1:(CGFloat)alpha1

shadeAlpha2:(CGFloat)alpha2

shadeAlpha3:(CGFloat)alpha3

shadowColor:(UIColor *)shadowColor

shadowOffset:(CGSize)shadowOffset

shadowBlur:(CGFloat)shadowBlur {

UIImage *image = self;

CGColorRef cgColor = [bgColor CGColor];

CGColorRef cgShadowColor = [shadowColor CGColor];

CGFloat components[16] = {1,1,1,alpha1,1,1,1,alpha1,1,1,1,alpha2,1,1,1,alpha3};

CGFloat locations[4] = {0,0.5,0.6,1};

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

CGGradientRef colorGradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, (size_t)4);

CGRect contextRect;

contextRect.origin.x = 0.0f;

contextRect.origin.y = 0.0f;

contextRect.size = [image size];

//contextRect.size = CGSizeMake([image size].width+5,[image size].height+5);

// Retrieve source image and begin image context

UIImage *itemImage = image;

CGSize itemImageSize = [itemImage size];

CGPoint itemImagePosition;

itemImagePosition.x = ceilf((contextRect.size.width - itemImageSize.width) / 2);

itemImagePosition.y = ceilf((contextRect.size.height - itemImageSize.height) / 2);

UIGraphicsBeginImageContext(contextRect.size);

CGContextRef c = UIGraphicsGetCurrentContext();

// Setup shadow

CGContextSetShadowWithColor(c, shadowOffset, shadowBlur, cgShadowColor);

// Setup transparency layer and clip to mask

CGContextBeginTransparencyLayer(c, NULL);

CGContextScaleCTM(c, 1.0, -1.0);

CGContextClipToMask(c, CGRectMake(itemImagePosition.x, -itemImagePosition.y, itemImageSize.width, -itemImageSize.height), [itemImage CGImage]);

// Fill and end the transparency layer

CGContextSetFillColorWithColor(c, cgColor);

contextRect.size.height = -contextRect.size.height;

CGContextFillRect(c, contextRect);

CGContextDrawLinearGradient(c, colorGradient,CGPointZero,CGPointMake(contextRect.size.width*1.0/4.0,contextRect.size.height),0);

CGContextEndTransparencyLayer(c);

//CGPointMake(contextRect.size.width*3.0/4.0, 0)

// Set selected image and end context

UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

CGColorSpaceRelease(colorSpace);

CGGradientRelease(colorGradient);

return resultImage;

}
           
- (UIImage *)composeWithHeader:(UIImage *)header content:(UIImage *)content footer:(UIImage *)footer{

CGSize size = CGSizeMake(content.size.width, header.size.height +content.size.height +footer.size.height);

UIGraphicsBeginImageContext(size);

[header drawInRect:CGRectMake(0,0,header.size.width,header.size.height)];

[content drawInRect:CGRectMake(0,header.size.height,content.size.width,content.size.height)];

[footer drawInRect:CGRectMake(0,header.size.height+content.size.height,footer.size.width,footer.size.height)];

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return image;

}

PCH    
http://www.jianshu.com/p/67ce72c4ad6c
app           
http://www.jianshu.com/p/d1ecc467faff
http://www.jianshu.com/p/a7aab7f04639
http://www.jianshu.com/p/d466f2da0d33
http://www.jianshu.com/p/1cb03ec1cb0b
http://www.jianshu.com/p/b7173ccd4241
http://www.jianshu.com/p/1f2572c08816
http://www.jianshu.com/p/420a66beb0c1
http://www.jianshu.com/p/2c38e7dc738a
http://www.jianshu.com/p/2c48aef39142
http://blog.csdn.net/u010818357/article/details/51221002
http://www.2cto.com/kf/201401/273820.html
http://blog.csdn.net/ztp800201/article/details/14222755
http://blog.csdn.net/qqmcy/article/details/48680601
http://blog.csdn.net/dean19900504/article/details/8673800/
https://yq.aliyun.com/articles/41371
      
#import 
- (void)vibrate {
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
1.            
                    ,                     .
2.      
iOS      
http://newdocx.appcan.cn/dev-guide/ios-certi-process
iOS      AppStore  
http://newdocx.appcan.cn/dev-guide/ios-dev-appStore
3.collectionView cell      
// cell           
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath  
{  
    return YES;  
}  
  
- (void)collectionView:(UICollectionView *)colView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath  
{  
    UICollectionViewCell* cell = [colView cellForItemAtIndexPath:indexPath];  
    //  (Highlight)        
    [cell setBackgroundColor:[UIColor colorWithString:@"f2f2f2"]];  
}  
  
- (void)collectionView:(UICollectionView *)colView  didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath  
{  
    UICollectionViewCell* cell = [colView cellForItemAtIndexPath:indexPath];  
    //  (Nomal)          
    [cell setBackgroundColor:[UIColor whiteColor]];  
}
4. webView          
warning:This application is modifying the autolayout engine from a background thread

    :This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.

    :                UI  , UI                

    :

dispatch_async(dispatch_get_main_queue(), ^{

      

});

5.     

LSApplicationQueriesSchemes

    
    wechat
    weixin

    
    sinaweibohd
    sinaweibo
    sinaweibosso
    weibosdk
    weibosdk2.5

    
    mqqapi
    mqq
    mqqOpensdkSSoLogin
    mqqconnect
    mqqopensdkdataline
    mqqopensdkgrouptribeshare
    mqqopensdkfriend
    mqqopensdkapi
    mqqopensdkapiV2
    mqqopensdkapiV3
    mqqopensdkapiV4
    mqzoneopensdk
    wtloginmqq
    wtloginmqq2
    mqqwpa
    mqzone
    mqzonev2
    mqzoneshare
    wtloginqzone
    mqzonewx
    mqzoneopensdkapiV2
    mqzoneopensdkapi19
    mqzoneopensdkapi
    mqqbrowser
    mttbrowser

    
    alipay
    alipayshare

    
    renrenios
    renrenapi
    renren
    renreniphone

    
    laiwangsso

    
    yixin
    yixinopenapi

    
    instagram

    
    whatsapp

    
    line

    
    fbapi
    fb-messenger-api
    fbauth2
    fbshareextension

      
     
        
    kakaofa63a0b2356e923f3edd6512d531f546
    kakaokompassauth
    storykompassauth
    kakaolink
    kakaotalk-4.5.0
    kakaostory-2.9.0

     
    pinterestsdk.v1

6.pod      
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master-1`.
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.

    :           Xcode
7.      
http://sharesdk.mob.com
https://www.juhe.cn
http://www.jisuapi.com
UITextfield       
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    if (range.length + range.location > textField.text.length) {
        return NO;
    }
    NSUInteger length = textField.text.length + string.length - range.length;
    return length <=       ;
}
8.NSTimer     
1.     

       1 NSTimer *timer = [NSTimer timerWithTimeInterval:5 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
       2 [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
2.     
3,     

9.    
//        
self.navigationController.navigationBar.barTintColor = mainColor;
//              
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:k6AutoSize(22)], NSForegroundColorAttributeName:[UIColor whiteColor]}];
//            
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
//         
UIScreenEdgePanGestureRecognizer *screenEdgePanGR = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(backEvent)];
screenEdgePanGR.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:screenEdgePanGR];
//  view      
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] init];
[tapGesture addTarget:self action:@selector(action)];
[view addGestureRecognizer:tapGesture];
//        
for (int i = 0; i < self.identityInformationView.nameTextField.text.length; i++) {
    NSRange range = NSMakeRange(i, 1);
    NSString *subString = [self.identityInformationView.nameTextField.text substringWithRange:range];
    const char *cString = [subString UTF8String];
    if (strlen(cString) != 3) {
    //    
    }
}
//         
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"100000";
  bundle ID
          ,     ;     App Store   , Apple Developer Center  App ID,         。
          ,      ,          bundle ID   com.apple.test(      )                 ,app ID            ,(  )com.baidu.test。              ,      bundle ID    com.baidu.test,      ,     ,          。
       info.plist    bundle ID  com.baidu.test。
      ,         The provisioning profile specified in your build settings ("test") has an AppID of "com.baidu.test" which does not match your bundle identifier "com.apple.test"    bundle identifier   info.plist       ,    Build Settings Package    Product Bundle Identifier    “com.baidu.test”

cell   
self.tableView.estimatedRowHeight = 100;
self.tableView.rowHeight = UITableViewAutomaticDimension;

100     ,       。       
cell.label.numberOfLines = 0;
//  
- (BOOL) validateEmail:(NSString *)email
{
    NSString *emailRegex =@"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:email];
}


//      
- (BOOL) validateMobile:(NSString *)mobile
{
    //    13, 15,18  ,   \d     
    NSString *phoneRegex =@"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
    NSPredicate *phoneTest = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:mobile];
}


//     
- (BOOL) validateCarNo:(NSString *)carNo
{
    NSString *carRegex =@"^[\u4e00-\u9fa5]{1}[a-zA-Z]{1}[a-zA-Z_0-9]{4}[a-zA-Z_0-9_\u4e00-\u9fa5]$";
    NSPredicate *carTest = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",carRegex];
    NSLog(@"carTest is %@",carTest);
    return [carTest evaluateWithObject:carNo];
}


//  
- (BOOL) validateCarType:(NSString *)CarType
{
    NSString *CarTypeRegex = @"^[\u4E00-\u9FFF]+$";
    NSPredicate *carTest = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",CarTypeRegex];
    return [carTest evaluateWithObject:CarType];
}


//   
- (BOOL) validateUserName:(NSString *)name
{
    NSString *userNameRegex = @"^[A-Za-z0-9]{6,20}+$";
    NSPredicate *userNamePredicate = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",userNameRegex];
    return [userNamePredicateevaluateWithObject:name];
}


//  
- (BOOL) validatePassword:(NSString *)passWord
{
    NSString *passWordRegex = @"^[a-zA-Z0-9]{6,20}+$";
    NSPredicate *passWordPredicate = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",passWordRegex];
    return [passWordPredicate evaluateWithObject:passWord];
}


//  
- (BOOL) validateNickname:(NSString *)nickname
{
    NSString *nicknameRegex =@"^[\u4e00-\u9fa5]{4,8}$";
    NSPredicate *passWordPredicate = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",nicknameRegex];
    return [passWordPredicate evaluateWithObject:nickname];
}


//    
- (BOOL) validateIdentityCard: (NSString *)identityCard
{
    if (identityCard.length == 15|| identityCard.length == 18) {
NSString *regex2 =@"^(\\d{14}|\\d{17})(\\d|[xX])$";
     NSPredicate *identityCardPredicate = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",regex2];
     return [identityCardPredicate evaluateWithObject:identityCard];
    }
    return NO;
}
//                   .             ,            
- (BOOL)isPureInt:(NSString *)string{
    NSScanner *scan = [NSScanner scannerWithString:string];
    int value;
    return [scan scanInt:&value] && [scan isAtEnd];
}
    // label         
    self.tailLabel.numberOfLines = 0;
    self.tailLabel.lineBreakMode = NSLineBreakByWordWrapping;
    CGSize size = [self.tailLabel sizeThatFits:CGSizeMake(self.tailLabel.frame.size.width, MAXFLOAT)];
    CGRect frame = self.tailLabel.frame;
    frame.size.height = size.height;
    self.tailLabel.frame = frame;
    //   label    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:tail];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:k6AutoSize(8)];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [tail length])];
    [self.tailLabel setAttributedText:attributedString];
    [self.tailLabel sizeToFit];
  
+ (ViewController *)sharedViewController
{
    static ViewController *VC = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        VC = [[ViewController alloc] init];
    });
    return VC;
}
      
    
①cd        
②    find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.h" -or -name "*.rss" ")" -print | xargs wc -l
   
//      ,               
#define alert(string, detail) UIAlertController *alertController = [UIAlertController alertControllerWithTitle:string message:detail preferredStyle:UIAlertControllerStyleAlert]; \
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"  " style:UIAlertActionStyleDefault handler:nil]; \
[alertController addAction:okAction]; \
[self presentViewController:alertController animated:YES completion:nil];

//          
alert(@"    ", @"     ")
  alert(@"    ", nil)
   
          :
self.imageView = [[UIImageView alloc] init];
self.imageView.backgroundColor = [UIColor redColor];
self.imageView.image = [UIImage imageNamed:@"12345"];
self.imageView.frame = CGRectMake(0, 0, 100, 100);
[self.view addSubview:self.imageView];
            :
self.imageView = ({
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.backgroundColor = [UIColor redColor];
    imageView.image = [UIImage imageNamed:@"12345"];
    imageView.frame = CGRectMake(0, 0, 100, 100);
    [self.view addSubview:imageView];
    imageView;
});

좋은 웹페이지 즐겨찾기