settext到uitextview应用程序崩溃 - ios sdk
问题描述:
我已经创建UITextView
以编程方式,textview是根据需要创建的,但是当我尝试使用标记应用程序崩溃时为textview设置值。settext到uitextview应用程序崩溃 - ios sdk
我可以设置其他参数,如setUserInteractionEnabled
没有问题。
它的代码如下..
创建的TextView使用标签的TextView
UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0,0,100,200)];
textView.font = [UIFont systemFontOfSize:30];
//textView.font = [UIFont boldSystemFontOfSize:12];
textView.backgroundColor = [UIColor grayColor];
textView.tag=i;
[textView setTextAlignment:NSTextAlignmentCenter];
textView.text=[NSString stringWithFormat:@"%d",i];
textView.inputView= [LNNumberpad defaultLNNumberpad];
textView.editable = YES;
[textView setDelegate:self];
[self.view addSubview:textView];
量变到质变值..
UITextView *txtviewfound = (UITextView *)[self.view viewWithTag:j];
[txtviewfound setText:@"some text"];
[txtviewfound setUserInteractionEnabled:FALSE];
当我评论的setText喜欢它工作正常。
如果我缺少任何东西,请让我知道。
在此先感谢
答
型铸造之前,你需要检查的天气子视图属于 TextView的还是不行,因为默认情况下为0的标签 值。如果您有任何其他对象中的每个对象你的看法然后它会创建 问题。
if([[self.view viewWithTag:i]isKindOfClass:[UITextView class]])
{
UITextView *txtviewfound = (UITextView *)[self.view viewWithTag:j];
[txtviewfound setText:@"some text"];
[txtviewfound setUserInteractionEnabled:NO];
}
+0
感谢@sunny你的时间...... :) – Satish 2014-11-01 11:00:54
答
什么是崩溃日志说?一个索引如果绑定可能? 另外可以肯定的是,不要将标签设置为像1到5这样的非常低的数字,它们很少但仍然可以被苹果公司采用。
我和j是什么? – Balu 2014-11-01 10:48:24
我和j有整数值,它的循环直到5 @Sunny – Satish 2014-11-01 10:49:40