iOS开发

iOS开发遇到的小问题 (未完待续......)

2017-01-05  本文已影响41人  insence
self.automaticallyAdjustsScrollViewInsets = NO;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
_tableView.separatorInset = UIEdgeInsetsZero;
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    CGFloat sectionHeaderHeight = sectionHead.height;
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView;.contentOffset.y>=0)
    {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    }
    else if(scrollView.contentOffset.y>=sectionHeaderHeight)
    {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
}
[scrollView.panGestureRecognizerrequireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
self.automaticallyAdjustsScrollViewInsets = NO;
self.navigationController.hidesBarsOnSwipe=YES;
label.attributedText = [self setLabelIndent:15 text:@"这里是内容"];
// indent是字体的大小, text是内容
-(NSAttributedString *)setLabelIndent:(CGFloat)indent text:(NSString *)text {
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.firstLineHeadIndent = indent * 2;
    NSDictionary *attributeDic = @{NSParagraphStyleAttributeName : paragraphStyle};
    NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:text attributes:attributeDic];
    
    return attrText;
}
_btn.adjustsImageWhenHighlighted = NO;
新建一个 ScrollView 继承 UIScrollView

重写 gestureRecognizer:(UIGestureRecognizer)gestureRecognizer  shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer)otherGestureRecognizer

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
   // 判断 otherGestureRecognizer 是不是系统 POP 手势
   if ([otherGestureRecognizer.view isKindOfClass:NSClassFromString(@"UILayoutContainerView")]) {

       // 判断 POP 手势的状态是 begin 还是 fail,同时判断 scrollView 的 ContentOffset.x 是不是在最左边
       if (otherGestureRecognizer.state == UIGestureRecognizerStateBegan && self.contentOffset.x == 0) {
           return YES;
       }
   }
   return NO;
}
// 拍照选择照片协议方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    
    NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
    if ([type isEqualToString:@"public.image"]) {
        UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
        UIImageOrientation imageOrientation=image.imageOrientation;
        if(imageOrientation!=UIImageOrientationUp)
            {
            UIGraphicsBeginImageContext(image.size);
            [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
            image = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();
            }
    }
}
上一篇 下一篇

猜你喜欢

热点阅读