I created native IOS av-player in Xamarin forms. every thing works fine but I need video-player should enter full-screen when user rotates the phone. I tried many solution nothing helps me.
currently is tried this
void DeviceRotated(NSNotification notification)
{
string rotaion = UIDevice.CurrentDevice.Orientation.ToString();
if (rotaion == "LandscapeLeft")
{
_playerViewController.ModalPresentationStyle = UIModalPresentationStyle.BlurOverFullScreen;
UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow();
UIViewController rootViewController = window.RootViewController;
_playerViewController.PresentModalViewController(rootViewController, true);
}
}
this didn't help me.
I can understand swift code as well.if any have good answer please share with me.
Related
I have xamarin forms app and need to prevent user from take screen shot or record screen
these implemented for android using these:
Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
is there any we to do these for ios
Thanks
Like Jason said, you could find more information in Google. You could try the code below for ios to blur or hide the screenshot taken, to hide sensitive information. I hope this would be helpful for you.
A easy way is to set a blur when the AppDelegate calls OnResignActivation.
UIVisualEffectView _blurWindow = null;
public override void OnActivated(UIApplication application)
{
base.OnActivated(application);
_blurWindow?.RemoveFromSuperview();
_blurWindow?.Dispose();
_blurWindow = null;
}
public override void OnResignActivation(UIApplication application)
{
base.OnResignActivation(application);
using (var blurEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Dark))
{
_blurWindow = new UIVisualEffectView(blurEffect)
{
Frame = UIApplication.SharedApplication.KeyWindow.RootViewController.View.Bounds
};
UIApplication.SharedApplication.KeyWindow.RootViewController.View.AddSubview(_blurWindow);
}
}
I use Dark here. You could change the blur effect to Light, Regular or any of the other options listed.
In iOS12 and below I used to use something similar to this to show a window on top of everything to cover my app contents. This use to work but in iOS13 betas this does not work anymore.
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var coverWindow: UIWindow?
func applicationDidEnterBackground(_ application: UIApplication) {
if self.coverWindow != nil {
// Skip since cover window is already showing
return
}
let vc = UIViewController()
let label = UILabel(frame: window!.bounds)
label.text = "CoverWindow. Tap to app see contents"
vc.view = label
vc.view.backgroundColor = UIColor.lightGray
let coverWindow = UIWindow(frame: window!.bounds)
coverWindow.rootViewController = vc
coverWindow.windowLevel = .alert
coverWindow.makeKeyAndVisible()
self.coverWindow = coverWindow
}
}
Apparently window changes are not reflected in screen until app enters foreground again.
Question
Does anyone know how fix or workaround this? or maybe this approach is incorrect?
Any help would be highly appreciated
Notes
I don't use a simple view because my app might be showing other windows too and my requirement is to cover everything.
I don't use applicationWillResignActive because we want to only show coverWindow when it enters background. (TouchID authentication and other stuff might trigger applicationWillResignActive and coverWindow would incorrectly show)
Example code
Download Full working example code in Github (Run in iOS simulator 12 and 13 to see the difference)
You have to implement application life cycle, you just delete it , add those app life cycle functions and implement your codes , it ll be run without error
Answer to myself.
I reported this to Apple and it was fixed in iOS 13.1 or so. Latest version of iOS13 does NOT have this bug :)
So I have an odd issue and my google-fu utterly fails to even provide me the basis of where to start investigating, so even useful keywords to search on may be of use.
I have an iOS application written in swift. I have a model hooked up to receive notifications about external displays. On some adaptors, I'm able to properly detect and respond to the presence of an external display and programatically switch it out to be something other than a mirror (see code block below). But with another adaptor, instead of just 'magically' becoming a second screen, I'm asked to 'trust' the external device, and it simply mirrors the device screen. Not the intended design at all.
func addSecondScreen(screen: UIScreen){
self.externalWindow = UIWindow.init(frame: screen.bounds)
self.externalWindow!.screen = screen
self.externalWindow!.rootViewController = self.externalVC
self.externalWindow!.isHidden = false;
}
#objc func handleScreenDidConnectNotification( _ notification: NSNotification){
let newScreen = notification.object as! UIScreen
if(self.externalWindow == nil){
addSecondScreen(screen: newScreen)
}
}
#objc func handleScreenDidDisconnectNotification( _ notification: NSNotification){
if let externalWindow = self.externalWindow{
externalWindow.isHidden = true
self.externalWindow = nil
}
}
The worst issue here is that because I'm connecting to an external display to do this, I can't even run this code through the debugger to find out what is going on. I don't know where to even begin.
Any ideas?
Edit:
Thanks to someone pointing out wifi debugging, I can tell you my notifications are firing off, but they're both firing at the same time, one after the other, when the external adaptor is disconnected.
I am currently testing my xamarin iOS app on TestFlight with an iOS device. The app is running fine but the images in my UIButtons arent showing up at all.
Heres my button code:
_uiAttributes.myScheduleImage = UIImage.FromFile("images/myschedule.PNG");
_uiAttributes.myCareersImage = UIImage.FromFile("images/mycareer.PNG");
_uiAttributes.mySocialImage = UIImage.FromFile("images/mysocial.PNG");
_uiAttributes.FeedbackImage = UIImage.FromFile("images/feedback.PNG");
_uiAttributes.myDetailsImage = UIImage.FromFile("images/mydetails.PNG");
buttonList = new List<UIButton>
{
_uiControls.btn_MySchedule,
_uiControls.btn_MyCareer,
_uiControls.btn_MySocial,
_uiControls.btn_Feedback,
_uiControls.btn_MyDetails
};
buttonImageList = new List<UIImage>
{
_uiAttributes.myScheduleImage,
_uiAttributes.myCareersImage,
_uiAttributes.mySocialImage,
_uiAttributes.feedbackImage,
_uiAttributes.myDetailsImage
};
I pass this code through to a Draw method.
public void DrawImageButton(List<UIButton> buttonList, List<CGRect> buttonDimensionsList, List<UIImage> buttonImageList, UIView container)
{
for(int i = 0; i < buttonList.Count; i++)
{
buttonList[i].Frame = buttonDimensionsList[i];
buttonList[i].SetImage(buttonImageList[i], UIControlState.Normal);
container.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
buttonList[i].AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
container.AddSubview(buttonList[i]);
}
}
The buttons are showing up when i run it on a simulator but not my actual device.
I will attach an screenshot of my images below:
Resources/images
I have checked a number of related answers but theyre all in Xcode. I am currently using Visual Studio 2015 to develop my application.
If anyone can help or point me in the right direction that would be great.
So I have managed to fix this issue. The problem was that i never changed the Copy to Output Directory to "Copy Always" in the properties panel for each image. Also I had to state the path of the image being loaded.
_uiAttributes.myScheduleImage = UIImage.FromFile("images/myschedule.PNG");
Thanks for all the help!
I am making/made a game in landscape orientation and have a Facebook and a twitter button in the main menu to either open the app or Safari.
The problem I have is that the app or safari opens up in portrait mode and when I switch back to my game it briefly shows everything in portrait before changing back to landscape. It also shows you a multitasking preview in portrait.
It is not a big deal but obviously for that brief 1-2 seconds the game is in portrait mode everything is squashed and it looks sort of ugly and unprofessional. This only happens when you use those 2 social media buttons, when you just switch to a portrait app yourself via multitasking the game will stay in landscape upon return.
I have being trying to figure it out but I cannot find anything, especially for swift. Any help would be much appreciated. Thanks
PS. This is the code I used for the social media parts, I think its pretty straight forward and boiler plate.
//MARK: - Load Social Media
func loadFacebook() {
var appURL = NSURL(string: "APP ID HERE")
var webURL = NSURL(string: "WEB ID HERE")
if(UIApplication.sharedApplication().canOpenURL(appURL!)) {
// App
UIApplication.sharedApplication().openURL(appURL!)
} else {
// Safari
UIApplication.sharedApplication().openURL(webURL!)
}
}
func loadTwitter() {
var appURL = NSURL(string: "APP ID HERE")
var webURL = NSURL(string: "WEB ID HERE")
if(UIApplication.sharedApplication().canOpenURL(appURL!)) {
// App
UIApplication.sharedApplication().openURL(appURL!)
} else {
// Safari
UIApplication.sharedApplication().openURL(webURL!)
}
}
see here for answer as this is still an issue where there is not a lot of information about.
Swift sprite kit landscape only forced into portrait