04 2013 档案
摘要:UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];//后面还会重新设置其size。[label setNumberOfLines:0];NSString *s = @"string......";UIFont *font = [UIFont fontWithName:@"Arial" size:12];CGSize size = CGSizeMake(320,2000);CGSize labelsize = [s sizeWithFont:fontconstraine
阅读全文
摘要:今天项目中用[Object performSelectorInBackground:@selector(doSomething:) withObject:nil]开了个子线程,然后在这个线程中进行了一系列操作,结果发生了bool _WebTryThreadLock(bool), 0x1498120: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary th
阅读全文
摘要:request = [ASIHTTPRequest requestWithURL:url];[request setDelegate:self];[request startAsynchronous];这段本身没什么问题,在Navigation Controller驱动下,用户点快了之后,异步请求返回慢了,会出respondsToSelector:]: message sent to deallocated instance这种错误。也就是说delegate一般设置为自身,跳到另外一个view之后,自身会被回收,等到ASIHTTPRequest返回结果,准备调用requestFinished或
阅读全文
摘要:1、- (void)applicationWillResignActive:(UIApplication *)application说明:当应用程序将要入非活动状态执行,在此期间,应用程序不接收消息或事件,比如来电话了2、- (void)applicationDidBecomeActive:(UIApplication *)application说明:当应用程序入活动状态执行,这个刚好跟上面那个方法相反3、- (void)applicationDidEnterBackground:(UIApplication *)application说明:当程序被推送到后台的时候调用。所以要设置后台继续运行
阅读全文
摘要:转载集合一种是自己写缓存的处理,一种是采用ASIHTTPRequest中的ASIDownloadCache。根据我目前的技术水平和时间花费,我果断选择了后者,事实证明效果也很不错。下面说一下实现方法: 1、设置全局的Cache 在AppDelegate.h中添加一个全局变量[plain]@interface AppDelegate : UIResponder <UIApplicationDelegate>{ ASIDownloadCache *myCache;}@property (strong, nonatomic) UIWindow *window;@property (non
阅读全文
摘要:有时候我们需要程序退出后台或者程序在后台返回前台的时候触发一些事件,这时候我们就可以这样写来触发 [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector()name:UIApplicationDidBecomeActiveNotificationobject:nil];在selector里面添加要触发的事件就可以了,name就是你需要在什么notification触发这个事件 [[NSNotificationCenterdefaultCenter]removeObserver:selfname:UIAppli
阅读全文
摘要:添加addSubview:insertSubview:atIndex: (放到index层,越往下,index越小)insertSubview:aboveSubview:(把前一个View放在后一个View 的上面)insertSubview:belowSubview:(把前一个View放在后一个View 的下面)整理bringSubviewToFront: (把一个View放到上面)sendSubviewToBack:(把一个View放到下面)exchangeSubviewAtIndex:withSubviewAtIndex:(来修改遮挡。我的理解是view按照控件加进去的顺给了个index
阅读全文

浙公网安备 33010602011771号