草庐IT

main_background

全部标签

iphone - NSURLConnection 发送异步请求 : Blocking Main Thread

我正在使用NSURLConnection发出多个异步请求。我想显示一个进度指示器,以显示要执行的总数中已完成的请求数。但是,当我尝试在发出请求之前或在执行请求之前调用的另一个方法中设置和显示此进度指示器时,它不会显示。当请求被注释掉时,进度指示器显示正常。但如果不是,就好像Xcode向前看并看到异步请求到来并阻塞主线程,从而使UI更改变得不可能。下面是被调用的相关代码,包括请求和显示进度指示器的代码:-(void)getRegionalInformationFromChecked:(NSSet*)setatIndex:(NSInteger)index{__blockBOOLrespon

ios - 使用“dispatch_async(dispatch_get_main_queue(),^{block}) 更新 UI

我想在NSURLSession的完成block中更新UI。最初的实现并没有立即更新UI。它可能在20秒后更新了UI。这是最初的实现。NSURLSessionDataTask*task=[self.sessiondataTaskWithRequest:requestcompletionHandler:^(NSData*data,NSURLResponse*response,NSError*error){NSDictionary*jsonDict=[NSJSONSerializationJSONObjectWithData:dataoptions:0error:nil];UILabel*l

ios - 覆盖 drawRect(_ :) in UITableViewHeaderFooterView results in black background

1。空自定义View实现我创建了UITableViewHeaderFooterView的空子类,如下所示:classMyCustomHeaderView:UITableViewHeaderFooterView{}我用我的TableView注册了那个类:tableView.register(MyCustomHeaderView.self,forHeaderFooterViewReuseIdentifier:"myHeaderView")并实现数据源函数如下:functableView(_tableView:UITableView,viewForHeaderInSectionsection

iOS UITableView : changing background color of table overrides background color of cells

我遇到一个问题,即设置tableView的背景颜色会覆盖我为各个单元格设置的背景颜色。更具体地说,我有一个包含3行的表格:顶部单元格为深灰色,底部2个单元格为红色:http://imgur.com/otYlFMx,LvoLDzY,tXiJenw#0-(void)tableView:(UITableView*)tableViewwillDisplayCell:(UITableViewCell*)cellforRowAtIndexPath:(NSIndexPath*)indexPath{UIColor*sectionBackgroundColor=[UIColorcolorWithRed:

ios - GMSThreadException' 原因 : 'The API method must be called from the main thread'

我在使用googleAPI绘制折线时遇到此错误由于未捕获的异常GMSThreadException而终止应用程序-(void)drawRoute{dispatch_queue_tmyQueue=dispatch_queue_create("MyQueue",NULL);dispatch_async(myQueue,^{[selffetchPolylineWithOrigin:origindestination:destinationcompletionHandler:^(GMSPolyline*polyline){dispatch_async(dispatch_get_main_que

iOS,ARC : Background thread freezes UI

我有一个UIViewController和一个UITableView作为subview。单击某个单元格时,应显示一个UIImagePickerController。由于初始化时间较长,所以当UIViewController确实出现时,我在后台执行此过程。现在我将ARC添加到我的项目中,但它仍然无法正常工作。初始进程卡住了UI。这是我的代码。-(void)viewDidAppear:(BOOL)animated{[superviewDidAppear:animated];[selfperformSelectorInBackground:@selector(initImagePickerC

iOS - 在 main() 中捕获异常

所以,我有了一个想法,在ma​​in中捕获未预料到的异常,并尝试清理并优雅地退出:intmain(intargc,char*argv[]){@autoreleasepool{//returnUIApplicationMain(argc,argv,nil,NSStringFromClass([GRWAppDelegateclass]));@try{intretVal=UIApplicationMain(argc,argv,nil,NSStringFromClass([GRWAppDelegateclass]));returnretVal;}@catch(NSException*excep

iOS:dispatch_get_global_queue QOS_CLASS_BACKGROUND 在 7.1.2 上崩溃

我有以下使用block获取联系人的代码片段:if(&ABAddressBookCreateWithOptions!=NULL){CFErrorReferror=nil;addressBook=ABAddressBookCreateWithOptions(NULL,&error);ABAddressBookRequestAccessWithCompletion(addressBook,^(boolgranted,CFErrorReferror){dispatch_sync(dispatch_get_main_queue(),^{if(error){//...}elseif(!grante

ios - 无法结束 BackgroundTask : no background task exists with identifier 1fd57580, 或者它可能已经结束

AppDelegate.m文件包含-(void)applicationDidEnterBackground:(UIApplication*)application{UIBackgroundTaskIdentifiertaskID=[applicationbeginBackgroundTaskWithExpirationHandler:^{[applicationendBackgroundTask:taskID];}];}我不知道为什么我在gdb中收到这条消息Can'tendBackgroundTask:nobackgroundtaskexistswithidentifier1fd575

ios - 需要 iBeacon locationManager :didEnterRegion to trigger at near physical contact when backgrounded

这是我的挑战。我有一个配置为iBeacon的gimbal系列20,我的目标是让我的用户将他们的手机与应用程序后台的信标保持近距离物理接触。想想苹果支付。我已将发射功率一直设置为-23,但它仍然太强,并且信标正在触发DidEnterRegion委托(delegate)方法,距离可达一英尺。使用测距,我可以通过直接测量rssi来进一步设定阈值。该解决方案在应用程序运行时运行良好。我的问题是这个解决方案在后台运行不可靠,因为它在enterRegion事件后仅运行几秒钟然后停止。有没有办法进一步抑制信标的信号强度或其他方式导致locationManger:DidEnterRegion:触发较低