Android中可以有帶選項的警報對話框,如下圖:
但是iPhone應該怎麼實現類似的呢?
創建有代理名稱和屬性的MyCustomAlertViewController,創建 xib。然後這樣寫:
- (void) alertForAgentName: (NSString*) anAgentName agentPhoneNumber: (NSString*) anAgentPhoneNumber
{
MyCustomAlertViewController* modalViewController =
[[MyCustomAlertViewController alloc] initWithNibName: @"MyCustomAlertViewController" bundle:nil];
modalViewController.agentName = anAgentName;
modalViewController.agentPhoneNumber = anAgentPhoneNumber;
UINavigationController *modalViewNavController =
[[UINavigationController alloc]
initWithRootViewController: modalViewController];
[self.navigationController presentModalViewController:
modalViewNavController animated:YES];
// If MRC
[modalViewNavController release];
}
解除對話框時進行調用:
- (IBAction) dismissModalView:(id)sender
{
[self.parentViewController dismissModalViewControllerAnimated:NO];
}