Setting the orientation for only 1 fragment in my activity while the rest is in portrait

Use the following code line in the fragment where you want a specific (in this case portrait) orientation. getActivity().setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); If you want to have a orientation in a fragment, that is based on the way the user holds his device, then use the following code line. getActivity().setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); Hope, this will give you the … Read more

Get current orientation of iPad?

Orientation information isn’t very consistent, and there are several approaches. If in a view controller, you can use the interfaceOrientation property. From other places you can call: [[UIDevice currentDevice] orientation] Alternatively, you can request to receive orientation change notifications: [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; Some people also like to check the … Read more

shouldAutorotateToInterfaceOrientation not being called in iOS 6

PLEASE READ this CAREFULLY or you could loose 1-2 days of your life with going nuts and fighting, shaking, turning your test device like the chimp in the zoo which grabbed a visitor’s mobile! Sooner or later…promise 🙂 IN iOS 6 shouldAutorotateToInterfaceOrientation: is deprecated and replaced by shouldAutorotate it means iOS 6 will never call … Read more

Different ways of getting current interface orientation?

self.interfaceOrientation returns UIInterfaceOrientation, current orientation of the interface. It is a property in UIViewController, you can access to this one only in UIViewController classes. [[UIApplication sharedApplication] statusBarOrientation] returns UIInterfaceOrientation, current orientation of the application’s status bar. You can access to that property in any point of your application. My experience shows that it’s more effective … Read more

AVCaptureVideoPreviewLayer orientation – need landscape

Swift 5.5, Xcode 13.2 private func updatePreviewLayer(layer: AVCaptureConnection, orientation: AVCaptureVideoOrientation) { layer.videoOrientation = orientation self.previewLayer?.frame = view.bounds } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if let connection = self.previewLayer?.connection { let currentDevice = UIDevice.current let orientation: UIDeviceOrientation = currentDevice.orientation let previewLayerConnection: AVCaptureConnection = connection if previewLayerConnection.isVideoOrientationSupported { switch orientation { case .portrait: self.updatePreviewLayer(layer: previewLayerConnection, orientation: .portrait) … Read more

How Do I detect the orientation of the device on iOS?

Really old thread, but no real solution. I Had the same problem, but found out that getting The UIDeviceOrientation isn’t always consistent, so instead use this: UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if(orientation == 0) //Default orientation //UI is in Default (Portrait) — this is really a just a failsafe. else if(orientation == UIInterfaceOrientationPortrait) //Do something … Read more

Detecting iOS UIDevice orientation

Try doing the following when the application loads or when your view loads: [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]]; Then add the following method: – (void) orientationChanged:(NSNotification *)note { UIDevice * device = note.object; switch(device.orientation) { case UIDeviceOrientationPortrait: /* start special animation */ break; case UIDeviceOrientationPortraitUpsideDown: /* start special animation */ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)