日常记录未分类

XCODE 6的storyboard中view的大小调整

默认是一个正方形。两种方法调整:

1.选中view,右上角选择第一个页面(Show the file inspector),然后取消选择use size classes。

2.选中view,右上角选择倒数第二个页面(Show the Size inspector),然后选择Freeform,就可以设置尺寸了。

修改statusBar的颜色

1.修改plist文件,增加View controller-based status bar appearance,值设置为NO。

2.增加代码。一般是在didFinishLaunchingWithOptions中:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

如何使UIScrollView的滚动条indicator一直显示

http://kensou.blog.51cto.com/3495587/1040126

为storyborad中的viewController增加navigation bar

直接拖navigation bar到view中的方法不行,因为不会同时覆盖status bar。应该选中viewController,然后在右上角选择第四个页面(Show the Attribudes inspector),修改其中Top Bar的内容即可。tool bar也可以用这种方式添加。

禁止横屏

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}

XCode6在IOS7.1下不能全屏显示

1. Targets --> yourApp --> General -->App icons and launch images --> launch Images Source ;

2. 点击 Use Asset Catalog, 会弹出 Migrate launch images to an asset catalog 的提示,选择默认的 Images 选项,点 Migrate.

3.解决了ios7.1的问题,随之而来的时新问题:iPhone6和plus的屏幕一直是iphone5的screen height。原因是没有对应的Launch Image, 需要新建LaunchImage set,然后添加。

http://years.im/home/article/detail/id/51.html

 

设置storyboard的默认启动页

选中想要设置的viewController,右上角选择倒数第三个页面(Show the Attributes inspector),然后选择Is Initial View Controller。

如果一个storyboard没有Initial View Controller,会报错,类似"StoryboardApp[8593:207] Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set?"。

给UIView设置背景图片

[leftNaviView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"pabb_leftnaviview_bg.png"]]];  

保持不黑屏

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];  

 如果想变为可以黑屏,再改为NO就好了。

subView的位置超出父View仍然会显示,改为不能显示的方法

父View.clipsToBounds = YES;

 有篇文章是讲这种情况下的事件传递的,已保存。

全屏的tableView SetFrame不生效的解决方法

1.不使用Auto Layout

2.改变self.view的位置,让tableView跟着self.view自动变化位置和大小。

tableView.contentView的clipToBounds属性无效的问题 

建一个新的view,设为contentView的subView,并设置其frame跟tableView的contentView一样。以此view作为clipToBounds的View。

IOS7后台运行更新Core Location不生效

 设置-通用-后台应用程序刷新,打开总功能开关和APP的功能开关。

Core Location后台运行时设置为低经度

在后台开启gps会持快速续消耗电池,所以更好的方法是吧 在切换到后台后, 把原来高精度的gps 调用换成低精度的,来增加电池寿命。(即只有显著位置变化才会有响应)
在 applicationDidEnterBackground 中加入

if ([CLLocationManager significantLocationChangeMonitoringAvailable]) {
    [[GlobalVariables locationManager] stopUpdatingLocation];
    [[GlobalVariables locationManager] startMonitoringSignificantLocationChanges];
}else{
    NSLog(@"Significant location change monitoring is not available.");
}

在applicationDidBecomeActive 中加入

if ([CLLocationManager significantLocationChangeMonitoringAvailable]) {
    [[GlobalVariables locationManager] stopMonitoringSignificantLocationChanges];
    [[GlobalVariables locationManager] startUpdatingLocation];
}else {
    NSLog(@"Significant location change monitoring is not available.");
}

 Core Location进入某个区域后触发事件

调用CLLocationManager的startMonitoringForRegion:方法进行区域监测。区域监测结束时,可调用stopMonitoringForRegion:方法结束区域监测。

当设备进入指定区域时,iOS系统将会自动激发CLLocationManager的delegate对象的locationManager:didEnterRegion:方法;当设备离开指定区域时,iOS系统将会自动激发CLLocationManager的delegate对象的locationManager:didExitRegion:方法,开发者可重写这两个方法对用户进行提醒。

iOS提供了CLRegion来定义被监测的区域,但实际编程中推荐使用CLCircularRegion(CLRegion的子类)创建圆形区域,创建CLCircularRegion对象时无非就是指定圆心、半径等信息,非常简单。

 

原文地址:https://www.cnblogs.com/zhongriqianqian/p/4000837.html