Tag: ios5

Siri可以在应用程序中被禁用吗?

我在iOS游戏上工作,最近在iPhone 4S上testing过。 当我的拇指覆盖接近传感器时,Siri有时会激活。 这是4S的一个特点。 用户可以将手机放在耳边以激活Siri,而不必按住主屏幕button。 但在我的游戏中,激活并不是打算的,它会中断游戏。 Siri可以在应用程序中被禁用吗? 这是一个iPhone 4S的错误?

共享资源访问+ UI更新的GCD模式?

乡亲! 我在我的应用程序中实现共享caching。 这个想法是在后台从网上获取caching的数据,然后用新检索的数据更新caching和UI。 诀窍是确保线程安全,因为主线程将不断使用caching。 我不想以任何方式修改caching,而其他人可能会使用它。 我的理解是,使用@synchronized来locking对共享资源的访问并不是ObjectiveC中最优雅的方法,因为它陷入了内核,因此相当缓慢。 我一直使用GCD来阅读,而不是一个很好的select(现在让我们忽略它的表弟NSOperation),我想弄清楚我的情况是一个好的模式。 以下是一些示例代码: dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); // download the data in a background thread dispatch_async(queue, ^{ CacheData *data = [Downloader getLatestData]; // use the downloaded data in the main thread dispatch_sync(dispatch_get_main_queue(), ^{ [AppCache updateCache:data]; [[NSNotificationCenter defaultCenter] postNotificationName:@"CacheUpdated" object:nil]; }); }); 这实际上会做我认为的事情吗?如果是这样的话,这是迄今为止处理这种情况的最干净的方法吗? 有一篇博客文章与我正在谈论的内容非常接近,但是我也想仔细检查一下。 我在想,只要我只访问共享同一个线程/队列上的共享资源(主要在我的情况下),只有更新主要的UI,那么我将有效地实现线程安全。 那是对的吗? 谢谢!

在iOS中的UITableViewasynchronous图像加载的build议

我目前正在使用这个代码加载我的表左侧的缩略图,标题和副标题: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } NSDictionary *post = [posts objectAtIndex:indexPath.row]; cell.textLabel.text = [post objectForKey:@"post_text"]; cell.detailTextLabel.text = [post objectForKey:@"post_author_name"]; NSString *postpictureUrl = [post objectForKey:@"picture"]; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:postpictureUrl]]; cell.imageView.image […]

iOS 5后退button大小

我正在使用iOS 5 UIAppearance协议来使用自定义的导航栏后退button。 不像其他方法,我发现,这是最好的,因为它保留了默认的后退buttonanimation和行为。 唯一的问题是,我不能改变它的大小或设置它不剪辑子视图 。 这是发生了什么事情: A是预期行为,B是默认样式,C是剪辑结果。 不幸的是,这不像设置UIBarButtonItem到clipsToBounds = NO那么简单。 有谁知道如何解决这个问题? 谢谢!

尝试在MapView中模拟路线

我有一个从文件中parsing的CLLocation对象数组。 我想模拟用户正在沿着这条路线移动,我已经实现了这一点: for (CLLocation *loc in simulatedLocs) { [self moveUser:loc]; sleep(1); } 这是在循环中调用的方法: – (void)moveUser:(CLLocation*)newLoc { CLLocationCoordinate2D coords; coords.latitude = newLoc.coordinate.latitude; coords.longitude = newLoc.coordinate.longitude; CustomAnnotation *annotation = [[CustomAnnotation alloc] initWithCoordinate:coords]; annotation.title = @"User"; // To remove the previous location icon NSArray *existingpoints = self.mapView.annotations; if ([existingpoints count] > 0) { for (CustomAnnotation *annotation in existingpoints) […]

如何计算NSDictionary对象的总大小?

如何计算NSDictionary对象的总大小? 我有不同的密钥在NSDictionary 3000 StudentClass对象。 我想计算字典的总大小(以KB为单位)。 我用malloc_size()但它总是返回24( NSDictionary包含1对象或3000对象) sizeof()也总是返回相同的。

自定义UITableViewCell,UITableView并允许MultipleSelectionDuringEditing

我在使用iOS 5新function在编辑模式下select多个单元时遇到问题。 应用程序结构如下: -> UIViewController —> UITableView —-> CustomUITableViewCell UIViewController是UITableView的委托和数据源(我使用的UIViewController而不是UITableViewController由于要求的原因,我不能改变它)。 单元格像下面的代码一样被加载到UITableView 。 – (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { CustomTableViewCell *cell = (CustomTableViewCell*)[tv dequeueReusableCellWithIdentifier:kCellTableIdentifier]; if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"CustomTableViewCellXib" owner:self options:nil]; cell = self.customTableViewCellOutlet; cell.selectionStyle = UITableViewCellSelectionStyleNone; } // configure the cell with data [self configureCell:cell atIndexPath:indexPath]; return cell; } 单元接口已经从xib文件创build。 特别是,我创build了一个新的xib文件,其中superview由一个UITableViewCell元素组成。 […]

如何使#key和@key在IOS7中可点击

任何人都知道如何使IOS7中的注释文本中的#KEY和@NAME可点击(例如,instagram就是这样)? 我想使用NSMutableAttributedString,但我不知道如何检测点击事件,在下面的图像中单击@用户名应使用户的configuration文件的用户

在Xcode 4.2 / iOS5中模拟包括移动的位置

我已经看到苹果在iOS5中演示了新的模拟器function,除了静态位置之外,他们展示了模拟运行在模拟器上的应用程序位置移动的能力。 我已经使用GPX文件成功地模拟了单个位置,但我找不到任何模拟移动的方法。 这个function是否在最后一分钟掉线了,还是我错过了一些明显的东西?

在多任务栏中closuresPhoneGap应用程序时,iOS 5.1是否清除localStorage?

我有一个应用程序,将读取器的书签保存到localStorage中。 当我closures在iOS 5.1的应用程序书签已经消失,但在5.0.1它仍然存在?