草庐IT

Self-Blended

全部标签

ios - NSPredicate SELF CONTAINS[c] 首先返回较长文本中包含的值

我正在使用UISearchBar对UITableView进行排序。表格中填充的数组中的每个值最多可以有3个单词@“菠萝”、@“菠萝绿”、@“苹果绿”、@“生苹果绿”...我正在使用下面的NSPredicate方法:NSArray*words=[textcomponentsSeparatedByString:@""];NSMutableArray*predicateList=[NSMutableArrayarray];for(NSString*wordinwords){if([wordlength]>0){NSPredicate*pred=[NSPredicatepredicateWit

ios - 无法应用 addConstraints :NSLayoutConstraint to self. 窗口

我正在尝试为状态栏添加背景。当我尝试将VFL约束添加到self.window时出现错误unexpectedinterfacename:'NSLayoutConstratint'-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{//Overridepointforcustomizationafterapplicationlaunch.UIScreen*screen=[[UIScreenalloc]init];UIWindow*wi

ios - 为什么 myInstance = nil 而不是 self.myInstance = nil?

我为什么要使用(在我的dealloc方法中)?[myInstancerelease]而不是[self.myInstancerelease]myInstance=nil而不是self.myInstance=nil尽管我们使用self.myInstance=[[[AClassalloc]init]autorelease]而不是myInstance=[[[AClassalloc]init]autorelease]?这些做法来self在网络上看到的众多示例。 最佳答案 1)[myInstancerelease]insteadof[self.

iphone - iOS 开发 : What are some reasons that [[self navigationController] viewControllers]; would return nil?

下面的语句返回一个nil...NSArray*viewControllersInNavStack=[[selfnavigationController]viewControllers];并且在导航堆栈中大约四层深的ViewController中调用此语句,所以我不明白它如何或为什么会返回nil。你的想法?非常感谢您的智慧! 最佳答案 听起来不像是你的问题,但文档说“如果ViewController在其堆栈中,则只返回导航Controller。如果找不到导航Controller,则此属性为nil”。首先检查[selfnavigatio

objective-c - self 释放后

我正在使用第三方Objective-C库,它在后台线程中发出网络请求,然后使用[selfperformSelectorOnMainThread:...]返回结果,然后调用委托(delegate)方法。我知道在释放委托(delegate)之前我需要nil委托(delegate)引用,但我想知道如果在后台线程运行时这个请求对象本身被释放会发生什么。此内部self引用是否会设置为nil以便-performSelectorOnMainThread:调用是无害的,还是这里有可能发生崩溃? 最佳答案 据我了解您的情况(但您可能应该包括一些代码)

iOS - self.view.frame.size.width 为 0.00000

我有一个ViewController(SecondViewController),它有一个名为setupHomeScreen的方法,该方法从另一个ViewController(FirstViewController)调用。此方法在SecondViewController初始化后调用。在setupHomeScreen中,创建了一个UIView,我希望它具有与主视图相同的边界,这取决于iPad是以纵向还是纵向方式查看横向模式。第一次调用该方法时(应用程序启动时),View完全错误,NSLog输出显示self.view.frame.size.width等于0.0000。如果我导航到Third

ios - self.fetchedResultsController 抛出 EXC_BAD_ACCESS 而 _fetchedResultsController 工作正常

my.h:@property(nonatomic,retain)NSManagedObjectContext*context;//ManagedObjectContextofCoreData.PassedfromAppDelegate@property(nonatomic,retain)NSFetchedResultsController*fetchedResultsController;//FetchedResultsControllerformanagingfetchedobjectsfromcoreData.我的.m:-(NSNumber*)customMethod{NSErro

ios - 如果我的 UIView 设置为不透明,为什么它仍然被模拟器着色为 "blended"?

我有一个UILabel,在初始化时我将其设置为不透明(opaque=YES),如果我使用“DebugViewHierarchy”按钮预览View在运行时,我可以看到它确实设置为不透明,正如我所期望的那样。但是,如果我在iOS模拟器中打开颜色混合图层,相同的View是红色的,表明它是混合的,出于性能原因,我不希望这样。这是为什么?我究竟做错了什么?为什么它仍然是混合的? 最佳答案 一个View不是不透明的(即使你设置了opaque=YES)用于合成,除非它有一个不透明的backgroundColor。

objective-c - 会 self 保留在 block 内吗?

在调用block之前/之后,保留计数始终为1。来自appleblockdoc我们知道self应该保留。谁能知道为什么?NSLog(@"Beforeblockretaincount:%d",[selfretainCount]);void(^block)(void)=^(void){UIImage*img=[UIImageimageNamed:@"hometown.png"];[selfsetImage:img];NSLog(@"Afterblockretaincount:%d",[selfretainCount]);};block(); 最佳答案

objective-c - 带有用户提供的上下文和 [self autorelease] 的 UIAlertView

我查看了一些有关如何为UIAlertView提供上下文的想法。常见的答案是将其保存在字典或子类UIAlertView中。我不喜欢将上下文保存在字典中的想法,这是数据的错误位置。Apple不支持子类化UIAlertView,因此按照我的标准,这不是一个好的解决方案。我想出了一个主意,但我不确定该怎么做。创建作为UIAlertView委托(delegate)的上下文对象的实例。反过来,警报View上下文有它自己的委托(delegate),即ViewController。问题是释放内存。我将alertView.delegate设置为nil并调用[selfautorelease]以释放-ale