首页 文章 精选 留言 我的

精选列表

搜索[ios],共10000篇文章
优秀的个人博客,低调大师

[IOS]装载Storyboard中的ViewController

如上图所示,如何装载Storyboard中指定的ViewController? 首先,需要指定ViewController的ID,如上图右上方红色方框内的Storyboard ID。然后使用下面的代码: [cpp] view plain copy UIStoryboard*mainStoryboard=[UIStoryboardstoryboardWithName:@"MainStoryboard_iPhone"bundle:nil]; LeftViewController*leftController=[mainStoryboardinstantiateViewControllerWithIdentifier:@"leftViewController"]; 或者使用下面的代码: [cpp] view plain copy UIStoryboard*mainStoryboard=[UIStoryboardstoryboardWithName:@"MainStoryboard_iPhone"bundle:nil]; ViewController*leftController=[mainStoryboardinstantiateViewControllerWithIdentifier:@"leftViewController"]; UINavigationController*navController=[[UINavigationControlleralloc]initWithRootViewController:leftController]; 本文转蓬莱仙羽51CTO博客,原文链接:http://blog.51cto.com/dingxiaowei/1366405,如需转载请自行联系原作者

优秀的个人博客,低调大师

关于IOS屏幕的旋转问题

处理IPhone屏幕的旋转是我们经常遇到的,当你做一个应用既然满足竖屏又要满足横屏,这就要求我们会处理屏幕旋转的问题! 方法一:自动布局 1.将项目中界面的四种手持方式都点上; 2.取消Use Autolayout; 3.选择界面中某个控件然后到属性工具栏中去找到AutoSizing功能,勾选对应的绝对定位的线条 4.重写可以旋转的方法 -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } 方法二:手动布局一(通过代码改view种控件的坐标) 1.重写可以旋转的方法 -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } 2.勾选上项目中支持的四种手持类型 3.取消Use Autolayout 4.代码实现: //每当屏幕旋转的时候都会触发一个 -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { //如果是是横屏状态 if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ) { self.l1.frame = CGRectMake(20, 25, 110, 110); self.l2.frame = CGRectMake(162, 25, 110, 110); self.l3.frame = CGRectMake(304, 25, 110, 110); self.r1.frame = CGRectMake(20, 178, 110, 110); self.r2.frame = CGRectMake(162, 178, 110, 110); self.r3.frame = CGRectMake(304, 178, 110, 110);} } 方法三:手动布局二(在xib中新建一个支持横屏的view通过双view切换实现) 1.在xib文件中拖一个view控件,选择Orientation属性为横屏 2.布局好界面 3.将横纵view分别在controller.h文件中创建对应的属性,命名为 @property(retain,nonatomic)IBOutletUIView*landspaceView; @property(retain,nonatomic)IBOutletUIView*portatiorView; 4.代码实现 宏定义实现角度转弧度 #define degreesToRadia(x) (M_PI * (x) /180)//参数要加括号 ,尤其是参数附近特别要加括号 -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } //每当屏幕旋转的时候都会触发一个 -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { //如果是是横屏状态 if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ) { // self.l1.frame = CGRectMake(20, 25, 110, 110); // self.l2.frame = CGRectMake(162, 25, 110, 110); // self.l3.frame = CGRectMake(304, 25, 110, 110); // self.r1.frame = CGRectMake(20, 178, 110, 110); // self.r2.frame = CGRectMake(162, 178, 110, 110); // self.r3.frame = CGRectMake(304, 178, 110, 110); self.view = self.landspaceView; //self.view.transform = CGAffineTransformIdentity; self.view.transform = CGAffineTransformMakeRotation(degreesToRadia(270)); self.view.bounds = CGRectMake(0, 0, 480, 300); } else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { // self.l1.frame = CGRectMake(37, 20, 110, 110); // self.l2.frame = CGRectMake(37, 162, 110, 110); // self.l3.frame = CGRectMake(37, 304, 110, 110); // self.r1.frame = CGRectMake(190, 20, 110, 110); // self.r2.frame = CGRectMake(190, 162, 110, 110); // self.r3.frame = CGRectMake(190, 304, 110, 110); self.view = self.landspaceView; //self.view.transform = CGAffineTransformIdentity; self.view.transform = CGAffineTransformMakeRotation(degreesToRadia(90)); self.view.bounds = CGRectMake(0, 0, 480, 300); } else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) { self.view = self.portatiorView; self.view.transform = CGAffineTransformIdentity; self.view.bounds = CGRectMake(0, 0, 320, 460); } else if(toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { self.view = self.portatiorView; //self.view = self.landspaceView; //self.view.transform = CGAffineTransformIdentity; self.view.transform = CGAffineTransformMakeRotation(degreesToRadia(180)); self.view.bounds = CGRectMake(0, 0, 320, 460); } } 模拟屏幕旋转 commond + 方向键 本文转蓬莱仙羽51CTO博客,原文链接:http://blog.51cto.com/dingxiaowei/1366436,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS tabbar视图中隐藏tabbar

有时会遇到这样的情况:主框架是tabbar,tabbar中某个子视图是navigationcontroller,从navigationcontroller中弹出一个新的视图,新的视图需要隐藏tabbar,例如设置这种情形。 有个属性叫做hide bottom bar on push的。可以在属性面板中找到。勾上就可以实现隐藏的效果。 本文转自 卓行天下 51CTO博客,原文链接:http://blog.51cto.com/9951038/1772527,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码