2015-01-15 38 views
2

在iOS 8上面的代碼正常工作,但不是在iOS 7上,任何人都知道如何解決它?爲什麼我的CGAffineTransformMakeTranslation在iOS 7上不起作用?

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 
    // headerFixed is an UIView inside of a headerView, i wanna it to be fixed on Y:0 
    headerFixed.transform = CGAffineTransformMakeTranslation(0, MIN(scrollView.contentOffset.y, 0)); 
} 

在iOS 8: https://www.youtube.com/watch?v=-428J20xbzM&feature=youtu.be

在iOS 7(BUG): https://www.youtube.com/watch?v=Dd_jh0zs1f0&feature=youtu.be

+0

當你在7上運行這個時會發生什麼? – Chris

+0

它滾動一半的tableView速度,並不停止在y0 –

+0

看起來像我下面的解決方案工作,你會介意接受它嗎? –

回答

7

如果您在iOS 8 SDK構建項目,然後在iOS 7你手動得將點轉換爲視網膜設備上的像素;

考慮編寫這樣的事:

CGFloat dY = MIN(scrollView.contentOffset.y, 0); 
if ([UIDevice currentDevice].systemVersion.floatValue < 8) { 
    dY *= [UIScreen mainScreen].scale; 
} 
headerFixed.transform = CGAffineTransformMakeTranslation(0, dY); 

有雖然這開啓自動關閉佈局將足以解決您的問題的機會。

+0

您拯救了我的一天!謝謝。 –

相關問題