每日成长总结

2017-09-07  本文已影响33人  当优秀成为习惯
  isMemberOfClass:  该方法是判断对象是否是只属于当前类
  isKindOfClass: 该方法是判断对象属于当前类或者父类
static void setLastCellSeperatorToLeft(UITableViewCell* cell)
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }

    if([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){
        [cell setPreservesSuperviewLayoutMargins:NO];
    }
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer  
{  
    // 首先判断otherGestureRecognizer是不是系统pop手势  
    if ([otherGestureRecognizer.view isKindOfClass:NSClassFromString(@"UILayoutContainerView")]) {  
        // 再判断系统手势的state是began还是fail,同时判断scrollView的位置是不是正好在最左边  
        if (otherGestureRecognizer.state == UIGestureRecognizerStateBegan && self.contentOffset.x == 0) {  
            return YES;  
        }  
    }  
      
    return NO;  
} 

分析:由于Window的层次导致,默认的windowLevel是1。如果层次相同则会导致显示不正常。

解决:创建新的UIWindow时将windowLevel调高一个层次则可解决问题。附上代码

_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_window.windowLevel = UIWindowLevelNormal + 1;
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(OrientationDidChange:)name:UIDeviceOrientationDidChangeNotification object:nil];// 监听横竖屏
  - (void)OrientationDidChange:(NSNotification *)noti {
    self.navigationController.navigationBar.frame = CGRectMake(0, 0, ScreenX, 64);// 不设置回来会导致tabbar偏移
}
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [alert show];
        });
row =  count+maxCow-1/ maxCow
NSArray *array1 = @[@"2016-10-01",@"2016-10-02",@"2016-10-03",
                        
                        @"2016-10-01",@"2016-10-02",@"2016-10-03",
                        
                        @"2016-10-01",@"2016-10-02",@"2016-10-03",
                        
                        @"2016-10-01",@"2016-10-02",@"2016-10-03",
                        
                        @"2016-10-01",@"2016-10-02",@"2016-10-03",
                        
                        @"2016-10-01",@"2016-10-02",@"2016-10-03",
                        
                        @"2016-10-04",@"2016-10-06",@"2016-10-08",
                        
                        @"2016-10-05",@"2016-10-07",@"2016-10-09"];
    NSMutableArray *array = [NSMutableArray arrayWithArray:array1];
    
    NSMutableArray *dateMutablearray = [@[] mutableCopy];
    for (int i = 0; i < array.count; i ++) {
        
        NSString *string = array[I];
        
        NSMutableArray *tempArray = [@[] mutableCopy];
        
        [tempArray addObject:string];
        
        for (int j = i+1; j < array.count; j ++) {
            
            NSString *jstring = array[j];
            
            if([string isEqualToString:jstring]){
                
                [tempArray addObject:jstring];
                
                [array removeObjectAtIndex:j];
                j -= 1;
                
            }
            
        }
        
        [dateMutablearray addObject:tempArray];
        
    }
    
    NSLog(@"dateMutable:%@",dateMutablearray);
- (NSInteger)getDifferenceByDate:(NSString *)date {
        //获得当前时间
    NSDate *now = [NSDate date];
        //实例化一个NSDateFormatter对象
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        //设定时间格式
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *oldDate = [dateFormatter dateFromString:date];
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    unsigned int unitFlags = NSDayCalendarUnit;
    NSDateComponents *comps = [gregorian components:unitFlags fromDate:oldDate  toDate:now  options:0];
    return [comps day];
}
_configuretion = [[WKWebViewConfiguration alloc] init];
    // Webview的偏好设置
    _configuretion.preferences = [[WKPreferences alloc]init];
    _configuretion.preferences.minimumFontSize = 10;
    _configuretion.preferences.javaScriptEnabled = YES;
    _configuretion.processPool = [[WKProcessPool alloc] init];
    _configuretion.preferences.javaScriptCanOpenWindowsAutomatically = NO;
    ;
    // 通过js与webview内容交互配置
    WKUserContentController *userContentController = _configuretion.userContentController;
    
   // OC注册供JS调用的方法
    [userContentController addScriptMessageHandler:self name:@"productId"];
    //展示文章
    self.webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 64, ScreenX, ScreenY - 64 - 35) configuration:_configuretion];
#pragma mark - js回调
-(void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
    //userContentController 注册message的WKUserContentController;
    //message:js传过来的数据
    //id body:消息携带的信息 Allowed types are NSNumber, NSString, NSDate, NSArray, NSDictionary, and NSNull.
    //message.name  js发送的方法名称
    HZLog(@"jsMessage:%@",message);
    if ([message.name isEqualToString:@"productId"]) { // 跳转到产品详情
        // 获取ID
        NSString *shopId = message.body[@"productId"];
        [self getTheMoreMessageOfGoodsWithId:shopId];
    }
   
}
  if (scrollView.contentOffset.y>头部偏移量) {
        self.layout.sectionHeadersPinToVisibleBounds = YES;
    }else{
        self.layout.sectionHeadersPinToVisibleBounds = NO;
    }

打开这个第三方的文件,更改IQUIView+Hierarchy.m文件的topMostController如下:
 -(UIViewController *)topMostController  
{  
    NSMutableArray<UIViewController*> *controllersHierarchy = [[NSMutableArray alloc] init];  
      
    UIViewController *topController = self.window.rootViewController;  
      
    if (topController)  
    {  
        [controllersHierarchy addObject:topController];  
    }  
      
    while ([topController presentedViewController]) {  
          
        topController = [topController presentedViewController];  
        [controllersHierarchy addObject:topController];  
    }  
      
    UIViewController *matchController = [self viewController];  
      
//    while (matchController != nil && [controllersHierarchy containsObject:matchController] == NO)  
//    {  
//        do  
//        {  
//            matchController = (UIViewController*)[matchController nextResponder];  
//  
//        } while (matchController != nil && [matchController isKindOfClass:[UIViewController class]] == NO);  
//    }  
      
    return (UIViewController*)matchController;  
}
设置这个属性就可以和label一样显示在后面
checkBtn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
 解决方案:把[self.navigationItem setHidesBackButton:YES];去掉,然後把假装成返回按钮的UIBarButtonItem的title设置成@""。
 tab.estimatedRowHeight = 0;
//    tab.estimatedSectionHeaderHeight = 0;
//    tab.estimatedSectionFooterHeight = 0;
[self.title mas_remakeConstraints:^(MASConstraintMaker *make) {
        if (self.proprietaryImg.hidden) {
            make.left.mas_equalTo(12 * ScreenX / 375);
        }else{
            make.left.mas_equalTo(self.proprietaryImg.mas_right).offset(4);
        }
        make.right.mas_equalTo(-6);
        make.top.mas_equalTo(self.imageView.mas_bottom).mas_offset(9 * ScreenX / 375);
    }];

这个方法会删掉之前的布局,这样就不会冲突。

上一篇 下一篇

猜你喜欢

热点阅读