iPhone開發(fā)應(yīng)用之顯示無按鈕警告框
iPhone開發(fā)應(yīng)用之顯示無按鈕警告框是本文要介紹的內(nèi)容,主要講述的是警告框案例的實(shí)現(xiàn),我們一起來看詳細(xì)內(nèi)容講解。如果要顯示一個(gè)不需要用戶交互的異步信息,可以創(chuàng)建一個(gè)不帶按鈕的UIAlertView。
一般無按鈕的警告框有一個(gè)特點(diǎn),它不會自動(dòng)消失。因此,我們在做完事情之后要收到的讓警告框消失??梢哉{(diào)用此方法
- – dismissWithClickedButtonIndex:animated:
下面的代碼是創(chuàng)建一個(gè)無按鈕的UIAlertView,讓其在3s之后消失。
- UIAlertView *baseAlert;
- - (void) action: (UIBarButtonItem *) item
- {
- baseAlert = [[[UIAlertView alloc] initWithTitle:@"Please Wait" message:nil delegate:self
- cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
- [baseAlert show];
- // Create and add the activity indicator
- UIActivityIndicatorView *aiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
- aiv.center = CGPointMake(baseAlert.bounds.size.width / 2.0f, baseAlert.bounds.size.height - 40.0f);
- [aiv startAnimating];
- [baseAlert addSubview:aiv];
- [aiv release];
- // Auto dismiss after 3 seconds
- [self performSelector:@selector(performDismiss) withObject:nil afterDelay:3.0f];
- }
- - (void) performDismiss
- {
- [baseAlert dismissWithClickedButtonIndex:0 animated:NO];
- }
效果如下圖:
小結(jié):iPhone開發(fā)應(yīng)用之顯示無按鈕警告框的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!