Tag: cocoa touch

自动完成UITextField

我想自动从自定义值中完成文本字段 在这里研究了Google和SO UITextField Autocomplete – iPhone SDK 我试过这个: – (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if ([string isEqualToString:@"Fac"]) { _clientField.text = @"Factory"; } return YES; } 问题是我没有得到预测值inputFactory ,只是键入的值Fac 编辑 试图根据答案… – (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if ([string isEqualToString:@"Fac"]) { _clientField.text = [_clientField.text stringByReplacingCharactersInRange:range withString:@"Factory"]; } return NO; } 还是一样

animation时无法同时满足约束条件

我有六个用户约束设置与IB看起来像这样: H:|-(593)-[UIView(411)]-(20)-| V:|-(20)-[UIView(288)]-(396)-| 我通过更改约束然后调用layoutIfNeeded来增长和缩小视图。 例如,为了发展我的观点,我会做: H:|-(20)-[UIView(984)]-(20)-| V:|-(20)-[UIView(663)]-(20)-| 然后打电话 [UIView animateWithDuration:.5 animations:^{ [self.view layoutIfNeeded]; }]; 这种技术会增长和缩小我的观点,它看起来不错,但我给了一个相当混乱的警告: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the […]

UIBezierPath橡皮擦

我在iPad应用程序中使用UIBezierPath进行免费手绘。 我想为这个UIBezierPath应用橡皮擦。 但是我只想通过这条path擦除绘图。 我不能使用path颜色作为背景颜色,因为我在背景上有其他元素。 有谁能够帮助我。 以下是我的免费手绘图的代码。 – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor clearColor]; self.opaque = NO; lineWidths = 10; brushPattern = [UIColor greenColor]; pathArray = [[NSMutableArray alloc]init]; bufferArray = [[NSMutableArray alloc]init]; self.multipleTouchEnabled = NO; } return self; } – (void)drawRect:(CGRect)rect { for (NSMutableDictionary *dictionary in pathArray) { UIBezierPath […]

如何使用像这个用户一样的黑暗主题SFSafariViewController?

我在截图中看到一个StackOverflow问题,用户提出了一个黑暗的SafariViewController: https ://stackoverflow.com/a/36099965/998117 这是如何完成的? 我似乎无法使用UIAppearance 。

从ALAssetRepresentation中为CGImageRef设置最大大小

我目前使用下面的代码从iOS应用程序中的ALAsset获取UIImage。 ALAssetRepresentation *rep = [self.asset defaultRepresentation]; CGImageRef ref = [rep fullResolutionImage]; ALAssetOrientation orientation = [[self.asset valueForProperty:@"ALAssetPropertyOrientation"] intValue]; UIImage *image = [UIImage imageWithCGImage:ref scale:1.0 orientation:(UIImageOrientation)orientation]; 只要图像相当小(例如,使用设备的相机拍摄),此function就可以很好地工作。 但是,如果图片太大(6000px ^ 2以上),则在此步骤中应用程序将耗尽内存: CGImageRef ref = [rep fullResolutionImage]; 我想在应用程序崩溃之前检测此情况,或者(理想情况下)为返回的图像设置最大大小。 我知道fullScreenImage将返回一个较小的图像,但是应用程序需要从图像的更高分辨率进行缩放。 此外,使用资源的字节大小是不可靠的,因为高度压缩的格式(例如JPG)可能在封装大小方面很小,但是如果它们的像素大小(低细节图像,高度压缩的图像),则仍然消耗太多内存。 任何关于如何获取图像的尺寸和事先检测到这种情况的input,所以我可以取消加载和显示错误,或如何获得这样一个大型资产的较小版本将不胜感激。

UIWebView canGoBack和canGoForward总是返回NO

我想直接加载数据到UIWebView : [webView loadData:data MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil]; 数据是一些htmlstring包含一些外部链接。 我想基于UIWebView属性启用后退和前进button: self.forwardBtn.enabled = self.webView.canGoForward; self.backBtn.enabled = self.webView.canGoBack; 但是,即使在初始加载之后在Web视图中单击不同的链接之后, webView.canGoForward和webView.canGoBack总是返回NO 。 任何想法呢?

如何使用“getHue:saturation:brightness:alpha:”?

在UIColor iOS 5中有这个方法: – (BOOL)getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightness:(CGFloat *)brightness alpha:(CGFloat *)alpha 但我不明白我是如何在代码中使用它。 当然,我不需要说明这些组件中的每一个,如果我正在寻求从UIColor中得到这些?

为什么在设置约束条件时,我的UITableView报告自己是600×600,还是故事板中的内容?

我的UITableView ,当我在debugging器中的帧,报告其宽度和高度为600×600。 我把它固定在它的视图控制器的两侧,所以我不明白为什么它会报告这一点。 600×600是Any x Any Storyboard网格中的尺寸,但正如我所说,它应该更新。 这是一个小故障?

实例消息的接收者types是前向声明popToRootViewController

我已经看到了类似的错误。 但我不确定它在这种情况下如何适用 这是错误 Receiver type for instance message is a forward declaration 这是我的代码。 MyAppDelegate *appDel = (MyAppDelegate*) [[UIApplication sharedApplication] delegate]; [appDel.secondTabNavController popToRootViewControllerAnimated:NO]; 这里有什么问题,我该如何解决? 我澄清我的这段代码的用法是正确的,作为我的选项卡控制器中的每个选项卡的不同的导航控制器。 我这样做是因为我在每个控制器中推送视图。 几个UINavigation控制器,每个选项卡一个,从我的应用程序委托出口?

从自定义的UITableViewCell获取值

我有一个自定义的UITableViewCell有一个UISegmentedControl对象。 我的UITableView(问卷forms)有6个这个自定义单元格(6个​​分段控件)。 我无法获取段控件的selectedSegmentIndex 。 我的猜测是,表格生成后,单元格被释放。 我正在使用下面的代码获取值: MyCustomCell *q1 = (MyCustomCell *)[tableView cellForRowAtIndexPath:[NSIndexPath indexPathWithIndex:0]]; int segmentIndex = (int) q1.segmentedController.selectedSegmentIndex; int segmentIndex始终给出相同的值0而不pipe选定的索引是什么。