草庐IT

ios - [NSConcreteTextStorage 属性 :atIndex:effectiveRange:]: Range or index out of bounds error in NSMutableAttributedString

我正在尝试创建一个属性字符串,其中在字符串末尾附加了一个链接:funcaddMoreAndLessFunctionality(textView:UITextView){iftextView.text.characters.count>=120{letlengthOfString=255varabc:String=(somelongStringInitiallyAvailableasNSString).substringWithRange(NSRange(location:0,length:lengthOfString))abc+="...More"textView.text=abcle

iphone - 不重新加载 ImageView

我有20个按钮,每单击一个按钮,都会根据它们的标签值加载该数组图像。我的问题是只显示第一个按钮图像为什么我尝试了下面的代码。images=[[NSMutableArrayalloc]init];[imagesinsertObject:@"circle.png"atIndex:0];[imagesinsertObject:@"cone.png"atIndex:1];[imagesinsertObject:@"cube.png"atIndex:2];[imagesinsertObject:@"cuboid.png"atIndex:3];[imagesinsertObject:@"cylin

ios - UIView insertSubview atIndex 移动 subview 的奇怪行为

我有一个UIView,在本例中有4个subview。我希望能够更改subview的顺序,但我似乎无法使用[UIViewinsertSubview:atIndex:]在一个特定的情况下,如果我调用它将一个项目从索引2移动到索引1,它会将它放在索引0处。这是调试器输出:(lldb)poself.subviews(,,,)(lldb)poself.subviews[2](lldb)po[selfinsertSubview:self.subviews[2]atIndex:1](lldb)poself.subviews(,,,)如您所见,我试图将ViewC移到ViewA之后,但它移到了它之前。如

objective-c - 插入对象 : atIndex: - index 3 beyond bounds for empty array

我根据字典键创建一个数组:factsBuiltArray=[NSMutableArrayarrayWithCapacity:6];if([statusDictcount]==10){for(NSString*keyin[statusDictallKeys]){if([keyisEqualToString:@"currenciesAndConversions"]){[factsBuiltArrayinsertObject:keyatIndex:0];}elseif([keyisEqualToString:@"languageAndTranslations"]){[factsBuiltAr

ios - 为什么缓冲区需要在 NSInvocation 上被 __unsafe_unretained - getArgument :atIndex:?

我正在使用NSInvocation并需要从中检索其中一个属性。我正在使用以下代码,但我在调用[invocationinvoke];时有一些奇怪的行为:NSString*propertyName=nil;[invocationgetArgument:&propertyNameatIndex:3];我读到为了让它在ARC下工作,我们需要使用__unsafe_unretained:__unsafe_unretainedNSString*propertyName=nil;[invocationgetArgument:&propertyNameatIndex:3];成功了,很好!!但我想了解为什

iOS9 崩溃 : *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil

在iOS9中,我的应用程序SWPi在main.m中崩溃:#importintmain(intargc,char*argv[]){NSAutoreleasePool*pool=[[NSAutoreleasePoolalloc]init];intretVal=0;@try{NSLog(@"MAIN:");retVal=UIApplicationMain(argc,argv,nil,nil);}@catch(NSException*exception){NSLog(@"CRASH:%@",exception);NSLog(@"StackTrace:%@",[exceptioncallStac

ios - minimumInteritemSpacingForSectionAtIndex 和 minimumLineSpacingForSectionAtIndex 有什么区别

所以在文档中,它说:minimumInteritemSpacingForSectionAtIndex:对于水平滚动的网格,此值表示同一列中项目之间的最小间距。minimumLineSpacingForSectionAtIndex:对于水平滚动的网格,此值表示连续列之间的最小间距。我猜如果节数是1,我应该使用minimumInteritemSpacingForSectionAtIndex;当节数>1时,我应该使用minimumLineSpacingForSectionAtIndex。但是,我有一个水平滚动的CollectionView,部分数为1,项目数为2。当我设置minimumInt

ios - insertObject 异常 :atIndex: on iOS6

我在iOS6上(在带有CoreData的应用程序上)出现以下异常:"2012-10-1510:21:28.952MyApp[68650:c07]*由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'*-[__NSArrayMinsertObject:atIndex:]:对象不能为零'*首先抛出调用栈:(0x28e60120x2659e7e0x2899b6a0x2899a200x16469410x1642c670x164f8460x164f9080x6c5400x2057e830x28a53760x28a4e060x288ca820x288bf

objective-c - [__NSArrayM 插入对象 :atIndex:]: object cannot be nil - how determine where is the error?

我有一个带有异步事件的大项目,有时我会出错[__NSArrayMinsertObject:atIndex:]:objectcannotbenil,但我不知道在哪里抛出这个错误..我怎样才能捕捉到这个错误?我在进行操作insertobject:atIndex的任何地方都进行了断言,什么都没有..这是堆栈:***Terminatingappduetouncaughtexception'NSInvalidArgumentException',reason:'***-[__NSArrayMinsertObject:atIndex:]:objectcannotbenil'***Firstthro

iphone - 使用 "tableView:sectionForSectionIndexTitle:atIndex:"帮助滚动到 TableViewHeader?

我在TableViewController的标题中添加了一个搜索栏,并且还在“sectionIndexTitlesForTableView”数组中添加了一个“{search}”。现在在右侧,我得到了字母表中的字母+顶部的搜索符号...滚动到字母的部分(不是搜索字段)我使用了这个:-(NSInteger)tableView:(UITableView*)tableViewsectionForSectionIndexTitle:(NSString*)titleatIndex:(NSInteger)index{returnindex-1;}现在,当我单击字母A时,它会滚动到A部分,依此类推。只