帮助在iOS上的multithreading?

我有一个使用OpenEars和Flite库的应用程序。 问题是Flite库是资源密集型的,它冻结了我的应用程序。 我怀疑在后台线程上运行Flite会解决问题,但我不知道如何去做。 这就是说, 我如何在iOS中实现后台线程 ? 我会很感激,如果有人能指点我一些教程,分享一些示例代码,或任何一般的build议,可以帮助我解决这个问题。

如何以编程方式绘制三angular形

我有一个三angular形求解器,我想要一个方法来使用我从答案中得到的值在与之匹配的屏幕上绘制一个三angular形。

在哪里突出显示UICollectionViewCell:代表或细胞?

根据“ 集合视图编程指南”,应该处理UICollectionViewDelegate单元格高亮的可视状态。 喜欢这个: – (void)collectionView:(PSUICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath { MYCollectionViewCell *cell = (MYCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath]; [cell highlight]; } – (void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath { MYCollectionViewCell *cell = (MYCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath]; [cell unhighlight]; } 我不喜欢这种方法是,它增加了对细胞非常特定的代表的逻辑。 事实上, UICollectionViewCell通过highlighted属性独立pipe理突出显示的状态。 不会压倒一切setHighlighted:是一个更清洁的解决scheme,然后呢? – (void)setHighlighted:(BOOL)highlighted { [super setHighlighted:highlighted]; if (highlighted) { [self highlight]; } else { [self unhighlight]; } } 这种方法有什么缺点,而不是委托方法?

如何使用Swift iOS将操作添加到UIAlertViewbutton

我想添加另一个button,而不是“OK”button,应该closures警报。 我想要另一个button来调用某个function。 var logInErrorAlert: UIAlertView = UIAlertView() logInErrorAlert.title = "Ooops" logInErrorAlert.message = "Unable to log in." logInErrorAlert.addButtonWithTitle("Ok") 如何添加另一个button到这个警报,然后让它调用一个function,一旦点击,让我们说我们希望新的button来调用: retry()

xcode 5.1 – 架构x86_64的未定义符号(zbar)

我已经将我的x代码版本从5.0更新到了5.1 我用ZBarSDK保护扫描条码。 在模拟器“iPhone视网膜(3.5英寸)”和“iPhone视网膜(4英寸)”,它工作正常。 但是当我想用模拟器“iPhone Retina(4英寸64位)”构build时,会出现以下错误。 ld: warning: ignoring file /Users/sayan/Desktop/ProjectAtanu/Omlis/Custom Classes/ZBarSDK/libzbar.a, missing required architecture x86_64 in file /Users/sayan/Desktop/ProjectAtanu/Omlis/Custom Classes/ZBarSDK/libzbar.a (3 slices) Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_ZBarReaderViewController", referenced from: objc-class-ref in HomeViewController.o "_ZBarReaderControllerResults", referenced from: -[HomeViewController imagePickerController:didFinishPickingMediaWithInfo:] in HomeViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 […]

以编程方式检测是否启用iOS密码

而不是直接在我的应用程序中build立密码,并可能要求用户input密码两次(一次为设备,一次为我的应用程序); 我以为自己可能会聪明一些,并按照以下的方式做一些事情: if (device has passcode) continue into my app else make user enter my app passcode 我不想设置设备密码,我不想强​​制屏幕locking,不encryption任何东西 – 我真正想要的只是一个API来检测设备密码是否有效。 就像是: BOOL notReally = [UIDevice isUserSlightlyMoreSecureBecauseTheySetDeviceLockOn]; 或者如果我感觉幸运的话 BOOL isPasscodeEnabled = [UIDevice isPasscodeEnabled]; BOOL isSimplePasscode = [UIDevice isSimplePasscode]; NSInteger minutes = [UIDevice requirePasscodeAfter]; 我猜不是基于这个问题(但是几年前)“ 编程检查iPhone的密码设置中的密码 ”或这可能是答案; “ 锁解锁事件iPhone ”这不正是我想要的,但可能“事后”的工作。

iPhone的iOS如何添加线性渐变到button的文本或图像下的UIButton?

我正在通过添加线性渐变到button来创build看起来很漂亮的UIbuttons。 但是我不知道在哪个索引我需要添加渐变。 我目前在图像/文字上放置了渐变的代码。 如何在文本/图像子图层下插入子图层到UIButton? 对我来说保持一个button的文本和图像是可见的! +(void)addLinearGradientToView:(UIView*)view TopColor:(UIColor*)topColor BottomColor:(UIColor*)bottomColor { for(CALayer* layer in view.layer.sublayers) { if ([layer isKindOfClass:[CAGradientLayer class]]) { [layer removeFromSuperlayer]; } } CAGradientLayer* gradientLayer = [CAGradientLayer layer]; gradientLayer.startPoint = CGPointMake(0.5, 0); gradientLayer.endPoint = CGPointMake(0.5,1); gradientLayer.frame = view.bounds; gradientLayer.colors = [NSArray arrayWithObjects:(id)[topColor CGColor], (id)[bottomColor CGColor], nil]; // [view.layer addSublayer:gradientLayer]; if(view.layer.sublayers.count>0) { [view.layer insertSublayer:gradientLayer atIndex:view.layer.sublayers.count-2]; }else […]

SDWebImage在滚动之前不会加载远程图像

我正在使用SDWebImage库将远程图像加载到使用我创build的自定义单元类的表视图中。 我只是使用 [cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"loading.jpg"]]; 在cellForRowAtIndexPath:现在的问题是它只在可见的单元格加载图像,而不是在屏幕外的单元格,我必须上下滚动,使他们加载。 有什么办法可以加载所有图像,而不必滚动表视图。 提前致谢!!

委托函数与callback函数

我在iOS平台上工作,我想知道什么是委托函数,什么是callback函数? 这两种函数有什么区别或者它们是相同的? 委托函数的numberOfRowsInSection是UITableViewDelegate协议中的numberOfRowsInSection ,callback函数的示例是didReceiveLocalNotification中的appDelegate.m 我们可以在Objective-C中创build自己的callback函数,如果是,举个例子… 谢谢..

如何从URL下载文件并存储在文档文件夹中

我创build了一个具有两个页面的应用程序(显示数据列表的第一页和显示详细数据的第二页)。 当点击任何一个单元格时,转到下一页,然后在下一个页面中存在一个button名称:DOWNLOAD,当我点击该button时,该文件将下载并保存到文档文件夹中。 我不知道。 请指导我如何下载任何文件并存储在文档文件夹中。 我在网上search,但我不明白这一点。 请告诉我如何用一个button下载任何文件的代码。 对不起,如果我不好英语。