Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在文本视图中添加文本格式(例如-means:jdfhjds,这里的意思应该始终与每个单词一起显示)_Objective C - Fatal编程技术网

Objective c 如何在文本视图中添加文本格式(例如-means:jdfhjds,这里的意思应该始终与每个单词一起显示)

Objective c 如何在文本视图中添加文本格式(例如-means:jdfhjds,这里的意思应该始终与每个单词一起显示),objective-c,Objective C,意思是我想要显示的文本格式,但出现错误。 这是我的密码: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. UIButton *del_btn =[[UIButton alloc] init]; [del_btn setBackgroundImage:[UIImage imageNamed:@"dele

意思是我想要显示的文本格式,但出现错误。 这是我的密码:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIButton *del_btn =[[UIButton alloc] init];
    [del_btn setBackgroundImage:[UIImage imageNamed:@"delete.png"] forState:UIControlStateNormal];

    del_btn.frame = CGRectMake(30, 0, 35, 35);
    UIBarButtonItem *del_btn1 =[[UIBarButtonItem alloc] initWithCustomView:del_btn];
    [del_btn addTarget:self action:@selector(deleteClicked:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = del_btn1;
    [self getListData];
    // word.text = [word ];
    //meaning.text= [NSString stringWithFormat:@"Meaning: %@",[]];

我建议您使用
NSAttributedString

此外,还将详细解释如何在
UITextView
中格式化文本

编辑:术后澄清:

这就是你要做的

NSArray *test = @[@"str1", @"str2", @"str3"];
NSString *cellString = [test componentsJoinedByString:@" "];
self.meaningTextView.text = [NSString stringWithFormat:@"Meaning : %@", cellString];

在从如下字符串替换子字符串后,可以通过其他方式进行尝试

NSString* preText = @"Meaning : hgdjksa";
NSString* newText = [preText stringByReplacingOccurrencesOfString:@"hgdjksa" withString:@"newText"];
NSLog("This is your text: %@", newText);

尝试
stringByReplacingOccurrencesOfString:withString:

假设
意思
这里有一个
UITextView
,您能解释一下您在这里看到的错误吗?实际上我有一个文本字段,需要显示单词的意思,它应该是这样的(意思:hgdjksa)这里冒号后面的词可以改变,但意思不能改变。请帮我看看。这相当简单。请看我编辑过的回复。你没有明白我的意思。我想显示(意思是:),冒号后面的单词是从另一个控制器传递过来的。您发送给我的答案将打印我在上次答复中提到的确切字符串:)。不,我抓到你了。在这里,您可以用从另一个视图控制器获得的任何数据替换测试。只需在此处用包含正确数据的对象替换
test
。让我知道这里是否有间隙。在我的示例中,我假设您将使用来自另一个视图控制器的字符串替换
test
。有多个字符串从另一个控制器传递,它将更改所有内容。您是获得字符串数组还是一个字符串接一个字符串?请分享一个来自另一个视图控制器的数据示例。这将真正有助于破解此问题:)。