Tag: ios

自定义UISearchBar:试图摆脱search栏下面的1px黑线

我的问题已经在标题中指定了:我想摆脱UISearchBar底部绘制的黑线。 有任何想法吗? 这是我的意思的图像: 更新 : 我认为这行是UITableView的tableHeaderView 。 我仍然不知道如何删除它。

如何在iOS中的UILabel上显示HTMLstring?

我正在以HTML格式获得一个标题 <p> <span style =“color:#000000;”> <strong>示例</ strong> </ span> </ p> 我需要在UILabel中显示这个HTMLstring。 颜色代码和字体大小应与HTML中的相同。 当我将HTMLstring转换为NSString时,只有文本“Example”即将出现,而不是颜色。 有没有解决办法? Thnx提前 直到现在我正在尝试通过以下方式使用NSAttributedString,但通过这种方式整个HTML打印: UIFont *font = [UIFont systemFontOfSize:14.0]; UIFont *secondFont = [UIFont systemFontOfSize:10.0]; NSMutableDictionary *firstAttributes; NSMutableDictionary *secondAttributes; NSDictionary *firstAttributeFont = @{NSFontAttributeName:font}; NSDictionary *secondAttributeFont = @{NSFontAttributeName:secondFont}; [firstAttributes addEntriesFromDictionary:firstAttributeFont]; [secondAttributes addEntriesFromDictionary:secondAttributeFont]; [firstAttributes addEntriesFromDictionary:@{NSForegroundColorAttributeName:[UIColor clearColor]}]; [secondAttributes addEntriesFromDictionary:@{NSForegroundColorAttributeName:[UIColor clearColor]}]; NSString* completeString = [NSString stringWithFormat:@"%@",strTitle]; NSMutableAttributedString […]

具有参数的Swift GET请求

我对swift非常陌生,所以我可能在代码中有很多错误,但是我想实现的是向参数localhost服务器发送一个GET请求。 更多,所以我试图实现它给我的函数采取两个参数baseURL:string,params:NSDictionary 。 我不知道如何将这两个结合到实际的URLRequest? 这是我到目前为止所尝试的 func sendRequest(url:String,params:NSDictionary){ let urls: NSURL! = NSURL(string:url) var request = NSMutableURLRequest(URL:urls) request.HTTPMethod = "GET" var data:NSData! = NSKeyedArchiver.archivedDataWithRootObject(params) request.HTTPBody = data println(request) var session = NSURLSession.sharedSession() var task = session.dataTaskWithRequest(request, completionHandler:loadedData) task.resume() } } func loadedData(data:NSData!,response:NSURLResponse!,err:NSError!){ if(err != nil){ println(err?.description) }else{ var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) […]

如何从xcode获取自己的应用程序版本?

我想知道在将代码放入xCode中的“Summary”选项卡后,是否有办法在代码中获取自己的应用程序版本。 一种方法似乎是searchInfo.plist的CFBundleVersion键,但有没有其他更简单,更方便的方法?

更改UITabBar高度

我使用UITabBarController作为根视图,应用程序支持iOS 6及以上版本。 项目类层次如下。 UITabBarController – tab1 – UINavigationController – UIViewController – UIViewController . . – tab2 – UINavigationController – UIViewController – UIViewController . . . – tab3 – UIViewController – tab4 – UIViewController 我使用下面的代码来更改上面的层次结构中UIViewControllers(位于UINavigationController )之一的UITabBar高度。 CGRect tabbarFrame = self.tabBarController.tabBar.frame; tabbarFrame.size.height += 60; self.tabBarController.tabBar.frame = tabbarFrame; 但它不改变高度。 UITabBar以默认高度显示。 虽然logging它的值打印更改值如下所示。 <UITabBar: 0xb528f60; frame = (0 431; 320 […]

如何在更改uiview隐藏模式的同时添加animation?

我想添加animation到一个视图,而改变其隐藏模式即 my_view.hidden=YES; 我在导航栏中添加了一个button。 当我们点击它时,新视图被设置为取消隐藏。 它在导航表的上部绘制。

如何在swift中着色UIImage?

我有一个arrowWhite图像。 我想将此图像着色为黑色。 func attachDropDownArrow() -> NSMutableAttributedString { let image:UIImage = UIImage(named: "arrowWhite.png")! let attachment = NSTextAttachment() attachment.image = image attachment.bounds = CGRectMake(2.25, 2, attachment.image!.size.width – 2.25, attachment.image!.size.height – 2.25) let attachmentString = NSAttributedString(attachment: attachment) let myString = NSMutableAttributedString(string: NSString(format: "%@", self.privacyOptions[selectedPickerRow]) as String) myString.appendAttributedString(attachmentString) return myString } 我想在blackColour得到这个图像。 tintColor不工作..

NSSet NSArray铸造调用objectAtIndex?

我试图更新MKMapView通过删除可见区域外的所有注释,并添加和删除可见区域内的一些注释。 这是我的代码: NSSet *visibleAnnotations = [mapView annotationsInMapRect:[mapView visibleMapRect]]; NSSet *allAnnotations = [NSSet setWithArray:[mapView annotations]]; NSMutableSet *nonVisibleAnnotations = [NSMutableSet setWithSet:allAnnotations]; [nonVisibleAnnotations minusSet:visibleAnnotations]; [mapView removeAnnotations:(NSArray *)nonVisibleAnnotations]; NSMutableSet *newAnnotations = [NSMutableSet setWithArray:[_zoomLevels objectAtIndex:clusterLevel]]; [newAnnotations minusSet:visibleAnnotations]; [mapView addAnnotations:(NSArray *)newAnnotations]; 这给了我错误– [__ NSCFSet objectAtIndex:]:无法识别的select器发送到实例0x13cd40最后一行后,我将newAnnotations投给NSArray然后添加注释。 有什么关于将一个数组转换成一个导致这个问题的集合吗? 如果是的话,有没有办法呢?

UICollectionViewselect并取消select问题

所以我有一个主要的对象,有许多图像相关联。 一个图像也是一个对象。 假设你有一个集合视图控制器,并且在你拥有的控制器中 cellForItemAtIndexPath 以及基于主要的对象,如果它有与之相关的当前图像,我想设置为true。 但是我希望用户能够在任何时候“取消”当前单元格以取消与主要对象的关联。 我发现如果你设置“select为真” – 如果主要对象和cellForItemAtIndexPath图像之间有关系,取消select不再是一个选项。 在 didDeselectItemAtIndexPath 和 didSelectItemAtIndexPath 我testing一个日志,看看他们是否被称为。 如果一个单元格被设置为选中 – 下一个被调用,但如果我从来没有设置单元格在cellForItemAtIndexPath中select我可以select和取消select所有我想要的。 这是集合视图应该工作的预期方式吗? 我阅读文档,似乎没有谈到这是如此。 我解释文档意味着它工作的表格视图单元格的方式。 有一些明显的变化 这也显示控制器设置正确,并使用适当的代表方法….嗯

使用 pathForResource:ofType:inDirectory访问文件:

我有一个名为TextFiles的文件夹中添加了一个TextFiles文件,这个文件夹位于Xcode的iOS项目的Resources文件夹中。 这是我用来访问文件的代码: NSString* filePath = [[NSBundle mainBundle] pathForResource:@"paylines" ofType:@"txt" inDirectory:@"TextFiles"]; NSLog(@"\n\nthe string %@",filePath); 代码打印: 2011-06-07 14:47:16.251 slots2[708:207] the string (null)