How to display temporary popup message on iPhone/iPad/iOS

后端 未结 10 999
孤城傲影
孤城傲影 2020-12-04 11:31

I\'d like to display a temporary message on the iPhone/iPad displaying confirmation of an action, or some quick status about some background activity.

Is there a st

10条回答
  •  我在风中等你
    2020-12-04 12:03

    Similar answer to @marco-mustapic's, but without inheritance.

    - (void)dismissAlert:(UIAlertView *)alertView
    {
        [alertView dismissWithClickedButtonIndex:0 animated:YES];
    }
    
    - (void)showPopupWithTitle:(NSString *)title
                        mesage:(NSString *)message
                  dismissAfter:(NSTimeInterval)interval
    {
        UIAlertView *alertView = [[UIAlertView alloc]
               initWithTitle:title
                     message:message
                    delegate:nil
            cancelButtonTitle:nil
            otherButtonTitles:nil
        ];
        [alertView show];
        [self performSelector:@selector(dismissAlert:)
                   withObject:alertView
                   afterDelay:interval
        ];
    }
    

    To use it:

    [self showPopupWithTitle:@"Hi" message:@"I like pie" dismissAfter:2.0];
    

    Throw it into a category on NSObject or something to always have it around.

提交回复
热议问题