ioscocoatouchtooltip

ToolTips in iOS through native UI Controls?


How do I create tooltips or something similar in iOS, without using any third party classes? I have a UIButton that I'd like to have a tooltip popup for a few seconds or until it's cleared. I have seen third party classes and libraries, but want to know if natively it's supported. I also want to show an arrow popping up from where the tooltip is coming from. I've seen some UIActionSheet Popups have this arrow.

Cheers, Amit


Solution

  • Well I ended up using the third party tooltip CMTopTipView afterall. It's relatively low overhead, just a header and implementation. Modified it slightly to account for ARC. Here is what I did:

    #import "CMPopTipView.h"
    
    CMPopTipView *navBarLeftButtonPopTipView;
    
    - (void) dismissToolTip
    {
       [navBarLeftButtonPopTipView dismissAnimated:YES];
    }
    
    - (void) showDoubleTap
    {
        navBarLeftButtonPopTipView = [[CMPopTipView alloc] 
           initWithMessage:@"DOUBLE Tap \n to view details"] ;
        navBarLeftButtonPopTipView.delegate = self;
        navBarLeftButtonPopTipView.backgroundColor = [UIColor darkGrayColor];
        navBarLeftButtonPopTipView.textColor = [UIColor lightTextColor];
        navBarLeftButtonPopTipView.opaque = FALSE;
        [navBarLeftButtonPopTipView presentPointingAtView:catButton1 
            inView:self.view animated:YES];
        navBarLeftButtonPopTipView.alpha = 0.75f;
    
        NSTimer *timerShowToolTip = [NSTimer scheduledTimerWithTimeInterval:5.0 
         target:self 
         selector:@selector(dismissToolTip) userInfo:nil repeats:NO];
    
     }