I have a long text which is truncated to three dots, i want the long text to show a small pop-up that contains the full text when the user clicks on the three dots.
this is the label of the text
self.lblTitle.text = self.project.title;
I have a long text which is truncated to three dots, i want the long text to show a small pop-up that contains the full text when the user clicks on the three dots.
this is the label of the text
self.lblTitle.text = self.project.title;
You can do this on using tapgesture
on the label and on taping the label a alertview
will show and on that alertview
you can show the full text what you want to show.
this is how we use tapgesture just example :-
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelTapped)];
tapGestureRecognizer.numberOfTapsRequired = 1;
[myLabel addGestureRecognizer:tapGestureRecognizer];
myLabel.userInteractionEnabled = YES;
One of the possible solutions is add a tapGesture. I've just made this code, you can try use it:
- (void)tapGestureToLabel {
self.lblTitle.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(callAlert)];
tapGesture.numberOfTapsRequired = 1;
[tapGesture setDelegate:self];
[self.lblTitle addGestureRecognizer:tapGesture];
}
- (void)callAlert {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:self.lblTitle.text delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alert show];
}
You can call [self tapGestureToLabel]; right after:
self.lblTitle.text = self.project.title;
ps: Don't forget to add UIGestureRecognizerDelegate to your @interface