user1894320
user1894320

Reputation:

UIButton + textView

I have a text view which have multi lines of data means scrolling.I also need to add feature of tapping on text area that will perform some action.

So to add this feature i placed a button over textview.All seems well but i am not able to scroll text view now because i placed the button.

Please help me or suggest me the way so i can achieve both feature scrolling + tapping to perform some action

this i also tried

[mybutton setTitle:@"dfsmnjksnfksndfkjsfkjsdkfjskdfjkdsjfkdsjfksjfkjsdknsmvnxcklvnlk;xvkgn'igsdmvkl'smv,ms,qdaasdasdsadasdvmsklmklvmlkdjffjksjksfkjhksdfjksjfksjfksjfksjdfkdjsfkdsjfkdjfksjdfkjsdfkjsdfkjskfjslfjslkfjlsdjflkdsjfklsjflksdjklsjkdsjfkjdfkjdsfkldskflsdfjsdfl" forState:UIControlStateNormal];
mybutton.titleLabel.lineBreakMode = UILineBreakModeCharacterWrap;

Upvotes: 0

Views: 229

Answers (2)

Rushi
Rushi

Reputation: 4500

Instead of using the UIButton what you can do is use

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

method to detect if user has touch the UITextView. You can use it as below:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    if( [touch view] == yourTextView)
    {
       // put the code you have written on button action.
    }
}

Upvotes: 0

Dmitry Shevchenko
Dmitry Shevchenko

Reputation: 32434

Look at gesture recognizers, specifically UITapGestureRecognizer.

Upvotes: 1

Related Questions