在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];
}

对于关闭对话框,您需要这样的调用(它在MyCustomAlertViewController类的内部):
- (IBAction) dismissModalView:(id)sender
{
    [self.parentViewController dismissModalViewControllerAnimated:NO];
}

关于iphone - iPhone单点触控中带有可选项目的警报 View ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17377002/

10-12 13:47