I am trying allow users to copy and paste my text content that sits in a UITextView. I have some title text, which is bold, followed by regular, unbolded text. Any way to set up a UITextView such that a single select-all copy/paste will work on both bold title and non-bold content text?
Currently, I am adding another UITextView and styling it as bold but this requires 2 select/select-all copy/paste operations:
txtView = [[UITextView alloc] initWithFrame:CGRectMake(0,60,280,300)];
[txtView setFont:[UIFont fontWithName:@"ArialMT" size:14]];
txtView.text = word.definition;
txtView.editable = NO;
txtView.scrollEnabled = YES;
[txtView scrollRangeToVisible:NSMakeRange([txtView.text length], 0)];
txtView.minimumZoomScale = 1;
txtView.maximumZoomScale = 10;
UITextView *wordTitle = [[UITextView alloc] initWithFrame:CGRectMake(0, 10, 320, 50)];
[wordTitle setFont:[UIFont boldSystemFontOfSize:14]];
wordTitle.text = word.term;
wordTitle.textAlignment = UITextAlignmentCenter;
[detailsViewController.view addSubview:wordTitle];
[detailsViewController.view addSubview:txtView];
[txtView release];
txtView = nil;
[htmlView release];
htmlView = nil;
[scrollView release];
scrollView = nil;
[[self navigationController] pushViewController:detailsViewController animated:YES];
[detailsViewController release];
I solved this by using a UIWebView and passing in a HTML string like so: