나는 아직도 코코아 터치에 너무 익숙해 져있어.UITextView의 특정 단어 위에 보이지 않는 uibuttons를 만드는 방법은 무엇입니까?
사용자에게 몇 가지 지침을 표시하는 앱을 디자인하려고합니다. UITextView를 통해 이러한 지시 사항을 표시하고 있으며 사용자가 특정 단어를 클릭하여 다른 단어보기의 정의를 볼 수있는 기능을 추가하려고합니다.
특정 단어는 모두 sqlite 데이터베이스에서 제공됩니다. 내 질문은 : 이것을 달성하는 가장 좋은 방법은 무엇입니까?
단어 위에 보이지 않는 UIButtons를 겹쳐서 생각하고 있었지만 UITextView 내부에 단어를 배치하는 방법을 모르겠습니다.
감사합니다.
// This assumes you have already determined the frame for the button
// i.e., you know the origin and size of the word in the UITextView
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundColor:[UIColor clearColor]];
[btn setFrame:wordFrame];
[textView addSubview:btn];
// Now, you need to also figure out how to handle the user pressing the button
[btn addTarget:self action:@selector(wordButtonWasPressed:) forControlEvents:UIControlEventTouchUpInside];
이제 다른 제안을 위해, 당신이 할 수 있습니다 : 당신이 그것을 요청했습니다으로
이것은 실제로 내 문제에 대한 꽤 우아한 해결책입니다!UITextView에서 특정 단어의 프레임/경계를 찾는 것이 훨씬 적은 작업처럼 보이기 때문에이 방향으로 나아갈 것입니다. 고맙습니다! – ad0ran