Şu anda bazı geçişler oluşturuyorum ve bir panning görünümü için CGAffineTransform
aracılığıyla dönüşüm yapıyorum ve iOS 7
ve iPhone 4
altında dönüşüm performansı nedeniyle sorun yaşıyorum.CGAffineTransforms performansı gerçekten yavaştır iOS 7
Istruments'da yaşadım ve eşyaları kaydettim ve dönüşümlerimi görünüme uygularken ağır kaldırma işlemi yapıldı. iOS 7 için
Güncel Uygulama
func handlePan(recognizer : UIPanGestureRecognizer) {
let drawerLocation = recognizer.locationInView(drawerView!)
let locationInView = recognizer.locationInView(containerView!)
let progressMax = containerView!.frame.height - 40 - 20
if(recognizer.state == .Changed) {
let offsetDrag = dragStartPosition.y - locationInView.y
let progress = Float(offsetDrag/progressMax)
if(offsetDrag >= 0) {
let positionTransform = CGAffineTransformMakeTranslation(0, -((containerView!.bounds.height - 40 - 20) * CGFloat(normalizedProgress)))
viewWithTransform.transform = positionTransform // really bad performance here
} else {
// reset the transition
}
}
}
Geçici çözüm
func handlePan(recognizer : UIPanGestureRecognizer) {
let drawerLocation = recognizer.locationInView(drawerView!)
let locationInView = recognizer.locationInView(containerView!)
let progressMax = containerView!.frame.height - 40 - 20
if(recognizer.state == .Changed) {
let offsetDrag = dragStartPosition.y - locationInView.y
let progress = Float(offsetDrag/progressMax)
if(offsetDrag >= 0) {
if UIDevice.currentDevice().systemMajorVersion() > 7 {
let positionTransform = CGAffineTransformMakeTranslation(0, -((containerView!.bounds.height - 40 - 20) * CGFloat(progress)))
viewWithTransform.transform = positionTransform // really bad performance here
} else {
viewWithTransform.frame = CGRectMake(0, -((containerView!.bounds.height - 40 - 20) * CGFloat(progress)), drawerView!.frame.size.width, drawerView!.frame.size.height); // works like a charm on iOS 7
}
} else {
// reset the transition
}
}
}
Soru
neden iOS 7'de kadar kötü performans ve CGAffineTransforms
ile benim iPhone 4 ? Çünkü ofset ile aynı şeyi yapıyor, sonra geçici çözümde çerçeve ayarını yapıyor. UIView.animateWithDuration()
'u dönüşümle kullandığımda 60 fps performans gösteriyor. IOS 7 temelindeki tüm uygulamayı yeniden yazmam için ne yapabilirim?
GÜNCELLEME 28th Temmuz AutoLayout'ın bu sorunla ilgili olabileceğini öğrendik. İşte TimeProfiler Stack benim şimdiki aramalardan: Ben AutoLayout güvenmek çünkü Şimdi, benim şimdiki uygulamada büyük bir sorun bakan değilim
. IOS 7'de bu sorunu çözmek için en kolay çözüm nedir?
'viewWithTransform.translate =' özel bir şey mi yoksa 'viewWithTransform.transform =' olması mı gerekiyor? Otomatik Düzen'i kullanarak (kasıtlı veya istemeden) mısınız? Sürüm oluşturmalarını kullanarak profil mi yapıyorsunuz? –