Tag: uitextview

当用Xcode bot运行时,UItesting在文本input到文本视图时失败

我有以下XCTest用户界面testing,将文本input到文本视图中。 let textView = app.textViews.elementBoundByIndex(0) textView.tap() textView.typeText("Hello world") 当作为Xcode机器人运行时,它显示了typeText调用的以下错误。 断言:UItesting失败 – 失败:超时等待关键事件完成 有趣的是,当我从同一台计算机上的Xcode手动运行testing时, 在升级到Xcode 7.1 / iOS 9.1之前,此testing也通过了Xcode bot。 什么可能是问题的根源? 这里是一个与UItesting隔离的演示: https : //github.com/exchangegroup/UITestTextViewDemo iOS 9.1模拟器,OS X 10.11.1(15B42),Xcode 7.1(7B91b),OS X Server 5.0.15(15S4033) 向苹果报告。

如何获得NSString的子string的NSRange(s)?

NSString *str = @" My name is Mike, I live in California and I work in Texas. Weather in California is nice but in Texas is too hot…"; 我怎样才能循环这个NSString并获得NSRange的每一个“加利福尼亚州”的发生,我想NSRange,因为我想改变它在NSAttributedstring中的颜色。 NSRange range = NSMakeRange(0, _stringLength); while(range.location != NSNotFound) { range = [[attString string] rangeOfString: @"California" options:0 range:range]; if(range.location != NSNotFound) { range = NSMakeRange(range.location + range.length, […]

将转换应用于UITextView – 防止内容大小调整

当我将一个旋转变换应用到UITextView ,然后点击里面开始编辑时,内容大小似乎会自动变宽。 内容视图的新宽度是旋转的视图的边界框的宽度。 例如,给定一个宽度为500,高度为400,旋转30度的文本框,新的内容宽度为: (500 * cos(30)) + (400 * sin(30)) = 633 或以graphics方式: 有趣的是,如果您已经在编辑文本视图,然后应用转换,那么似乎没有对内容大小进行修改。 因此,在文本编辑开始的某个时候,文本视图会查看其frame属性,并根据帧宽度调整内容大小。 我想这个解决scheme是告诉它使用bounds属性,但是我不知道该怎么做,因为我不确定文本视图在哪里决定修改内容的大小。 我google了,但似乎无法find使用转换UITextViews的任何引用。 有没有人有这个想法? 编辑(testing项目中的button动作): – (IBAction)rotateButtonTapped:(id)sender { if (CGAffineTransformIsIdentity(self.textView.transform)) { self.textView.transform = CGAffineTransformMakeRotation(30.0 * M_PI / 180.0); } else { self.textView.transform = CGAffineTransformIdentity; } NSLog(@"contentsize: %.0f, %.0f", textView.contentSize.width, textView.contentSize.height); }

增加uitableviewcell高度同时增加内部UITextView

我根据要显示的内容的types创build一个具有不同types的UITableViewCell 。 其中之一就是一个UITableViewCell ,里面有一个以这种方式编程创build的UITextView : – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { … if([current_field.tipo_campo isEqualToString:@"text_area"]) { NSString *string = current_field.valore; CGSize stringSize = [string sizeWithFont:[UIFont boldSystemFontOfSize:15] constrainedToSize:CGSizeMake(320, 9999) lineBreakMode:UILineBreakModeWordWrap]; CGFloat height = ([string isEqualToString:@""]) ? 30.0f : stringSize.height+10; UITextView *textV=[[UITextView alloc] initWithFrame:CGRectMake(5, 5, 290, height)]; textV.font = [UIFont systemFontOfSize:15.0]; textV.text = string; textV.autoresizingMask = UIViewAutoresizingFlexibleWidth; […]

如何在UIWebView而不是Safari中打开UITextView网页链接?

我正在开发和iPhone 3.0应用程序。 我试图打开UITextView的网页链接到UIWebView而不是Safari。 但是还是没有运气。 UITextView是不可编辑的,它完美地检测网页链接并在Safari中打开它们。 如何避免? 如何抓住这个url,所以我可以使用我自己的UIWebView ?

iPhone的UITextView设置行距

我怎样才能增加UITextView行空间,使它看起来像iPhone中的“Notes”应用程序?

将“填充”添加到UITextView

正如标题所说,我正在尝试向UITextView添加类似于填充的行为。 当视图在我的导航控制器中被推入并且出现以下代码时,生成textview: self.textView.layer.cornerRadius = 7; //pretty stuff is pretty NSString *description = appDelegate.productInDisplay.description; [self.textView setText:description]; //pretty stuff has content now CGRect frame = textView.frame; frame.size.height = textView.contentSize.height; textView.frame = frame; //set the UITextView to the size of it's containing text. self.textView.editable = NO; self.theScrollView.contentSize = CGSizeMake(320, 250 + textView.frame.size.height); //set the parent scrollView's height to […]

在iOS应用程序中创build日志文件

所以在我的应用程序中,我有一堆数据,我想写入日志文件,然后在单击button时在UITextView显示它。 我知道如何切换UITextView,但我不知道如何创build和更新日志文件(在本地文件系统中)。 谢谢你的帮助。

无法在UITextView上显示文本

我试图在我的UITextView上显示一个文本。 我正在做这个来显示文字 [_txtViewForScore setText:[_txtViewForScore.text stringByAppendingString:[NSString stringWithFormat:@"My Score:\n%@\n\n", str]]]; 它不显示任何东西在UITextView ,我不知道为什么。 谁能帮帮我吗? 这是我如何连接它 @property (strong, nonatomic) IBOutlet UITextView *txtViewForScore;

在textview中删除特性文字的单词

我正在实施类似Facebook的提及。 用户可以将他们的文本消息input到文本视图中,并提及用户名。 用户名将使用NSAttributedString高亮显示。 当用户想删除文本视图上的文本时,如果文本是提及名称的一部分,我想要删除整个提及的名称。 它不应该影响textview上的其他文字和其他提及的名称。 我正在尝试检测用户的变化 – (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text 但我似乎无法find一种方法来确定当前replacementText的归档string,并将其删除,而无需更改文本的其他部分。 谢谢您的帮助。