2016-07-19 6 views
0

wenn ich iOS-Bildschirm ohne Tastatur drehen, ist alles in Ordnung. aber mit der Tastatur, ich rotiere Bildschirm, die ganze Zelle geht schief. Ich weiß nicht, wie man auf Englisch erklärt, also habe ich Screenshot hochgeladen.Wenn ich den iOS-Bildschirm zu drehen, geht Sammlung Ansicht Zelle falsch

This is a Screenshot

+0

Möglicherweise verwenden Sie das automatische Layout. Ordnen Sie geeignete Einschränkungen für die Sammlungsansicht an. –

+0

setze führende und nachfolgende Einschränkungen –

Antwort

0

Swift Lösung

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { 
    if UIDevice.currentDevice().orientation.isLandscape.boolValue { 
     print("Landscape") 
     view.endEditing(true) 
    } else { 
     print("Portrait") 
     view.endEditing(true) 
    } 
} 

Objective-C-Lösung

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) ) 
{ 
    // do something for Portrait mode 
    [[self view] endEditing:YES]; 
} 
else if(([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) || ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft)) 
{ 
    // do something for Landscape mode 
    [[self view] endEditing:YES]; 
} 
+0

Ich hoffe es hilft dir –

0

verwendete ich view.frame.width für die automatische Layoutbeschränkungen.

bubbleWidthAnchor = bubbleView.widthAnchor.constraintEqualToConstant(view.frame.width/5*3) 

so.

Statt dieser

bubbleWidthAnchor = bubbleView.widthAnchor.constraintEqualToConstant(UIScreen.mainScreen().bounds.width/5*3) 

und es sieht gut aus.

Verwandte Themen