- tablview点击push到下一个页面,pop出来时位置下移了 ,解决办法:
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];
- ScrollView不能划到viewController顶部
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;
- iOS系统 POP 手势与 UIScrollView 手势冲突的解决方法
新建一个 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;
}
- UIImagePickerController拍照之后图片旋转的问题 ,解决办法:
// 拍照选择照片协议方法
- (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();
}
}
}
网友评论