- 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手勢和側(cè)滑手勢沖突
[scrollView.panGestureRecognizerrequireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
- ScrollView不能劃到viewController頂部
self.automaticallyAdjustsScrollViewInsets = NO;
self.navigationController.hidesBarsOnSwipe=YES;
label.attributedText = [self setLabelIndent:15 text:@"這里是內(nèi)容"];
// indent是字體的大小, text是內(nèi)容
-(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系統(tǒng) POP 手勢與 UIScrollView 手勢沖突的解決方法
新建一個 ScrollView 繼承 UIScrollView
重寫 gestureRecognizer:(UIGestureRecognizer)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer)otherGestureRecognizer
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
// 判斷 otherGestureRecognizer 是不是系統(tǒng) POP 手勢
if ([otherGestureRecognizer.view isKindOfClass:NSClassFromString(@"UILayoutContainerView")]) {
// 判斷 POP 手勢的狀態(tài)是 begin 還是 fail,同時判斷 scrollView 的 ContentOffset.x 是不是在最左邊
if (otherGestureRecognizer.state == UIGestureRecognizerStateBegan && self.contentOffset.x == 0) {
return YES;
}
}
return NO;
}
- UIImagePickerController拍照之后圖片旋轉(zhuǎn)的問題 ,解決辦法:
// 拍照選擇照片協(xié)議方法
- (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();
}
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。