赞助广告

 

年份

最新评论

评论 RSS

Xamarin.iOS自适应设备分辨率放大游戏视图

clock 二月 20, 2017 01:16 by author alex
//原游戏界面尺寸大小             float viewWidth = 800f; float viewHeight = 480f;             CGRect rect_screen = UIApplication.SharedApplication.Windows[0].Screen.Bounds;             CGSize size_screen = rect_screen.Size;             float scale_screen = (float)UIApplication.SharedApplication.Windows[0].Screen.Scale;             //获取iOS设备实际分辨率尺寸             float screenWidth = (float)((float)size_screen.Width * scale_screen);             float screenHeight = (float)((float)size_screen.Height * scale_screen);             //计算需要放大的倍数X方向,y方向             float scaleXValue = screenWidth / viewWidth;             float scaleYValue = screenHeight / viewHeight;             UIApplication.SharedApplication.Windows[0].RootViewController.View.Transform = CGAffineTransform.MakeScale(scaleXValue, scaleYValue);             //如果界面存在偏移,可用一下方法移动视图位置             UIApplication.SharedApplication.Windows[0].RootViewController.View.Frame = new CGRect(0 ,0, (int)screenWidth , (int)screenHeight);

解决unable to connect to address xxx xxx xxx xx with user xxxxxx方法

clock 十一月 3, 2016 19:06 by author alex
Xamarin Visual Studio安装高版本然后降级低版本链接Mac会出现unable to connect to address xxx xxx xxx xx with user xxxxxx 错误! 解决办法是删除C:\Users\当前用户\AppData\Local\Xamarin\MonoTouch目录中的id_rsa和id_rsa.pub文件 然后重起VS

Xamarin设置Orientation

clock 四月 1, 2016 10:49 by author alex
iOS: public class OrientationHandlerImplementation : IOrientationHandler { public void ForceLandscape() { UIDevice.CurrentDevice.SetValueForKey(new NSNumber((int)UIInterfaceOrientation.LandscapeLeft), new NSString("orientation")); } public void ForcePortrait() { UIDevice.CurrentDevice.SetValueForKey(new NSNumber((int)UIInterfaceOrientation.Portrait), new NSString("orientation")); } } Android: public class OrientationHandler : BaseDependencyImplementation, IOrientationHandler { public void ForceLandscape() { GetActivity().RequestedOrientation = ScreenOrientation.Landscape; } public void ForcePortrait() { GetActivity().RequestedOrientation = ScreenOrientation.Portrait; } } public class BaseDependencyImplementation : Object { public Activity GetActivity() { var activity = (Activity)Forms.Context; return activity; } }

友情链接赞助