Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何实现类似的菜单视图?[iOS]_Ios_Menu - Fatal编程技术网

如何实现类似的菜单视图?[iOS]

如何实现类似的菜单视图?[iOS],ios,menu,Ios,Menu,有没有一种方法可以通过sdk轻松实现此菜单,或者我必须手动创建它(将覆盖视图和其他视图与按钮相结合) 提前谢谢 这是标准UIKit框架中的UIActionSheet类这是标准UIKit框架中的UIActionSheet类这是我扩展了一点以触发调用操作的简单示例 ViewController全局范围内的Delcare: UIActionSheet*actionSheet和UIView*yourView 在viewDidLoad中输入: actionSheet = [[UIActionSheet

有没有一种方法可以通过sdk轻松实现此菜单,或者我必须手动创建它(将覆盖视图和其他视图与按钮相结合)


提前谢谢

这是标准UIKit框架中的UIActionSheet类

这是标准UIKit框架中的UIActionSheet类

这是我扩展了一点以触发调用操作的简单示例

ViewController全局范围内的Delcare:
UIActionSheet*actionSheet
UIView*yourView

在viewDidLoad中输入:

actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                             delegate:self
                             cancelButtonTitle:@"Cancel"
                             destructiveButtonTitle:@"Delete Note"
                             otherButtonTitles:@"Call",@"Add a Contact",nil];

[yourView = self.view]
要通过iAction的某个声明按钮启动菜单,您需要:

-(IBAction)viewMapButton:(id) sender
{
    [actionSheet showInView:yourView];

}
要根据用户选择采取适当的操作,请声明以下方法并检查
[actionSheet ButtonTitleIndex:buttonIndex]
等于:

- (void)actionSheet:(UIActionSheet *)actionSheet
        clickedButtonAtIndex:(NSInteger)buttonIndex
        {
        NSString * what_action = [actionSheet buttonTitleAtIndex:buttonIndex];
        NSLog(@"The %@ button was tapped.", what_action);
             if ([what_action isEqualToString:@"Call"])
                 {
                 NSString *phoneNumber = [[NSString alloc] 
                        initWithString:@"telprompt:1234567890"];
                 [[UIApplication sharedApplication] 
                        openURL:[NSURL URLWithString:phoneNumber]];
                 }
}
[注意:在iOS模拟器上启动呼叫不起作用]

我对UIActionSheet的简单示例进行了一些扩展,以启动呼叫操作

ViewController全局范围内的Delcare:
UIActionSheet*actionSheet
UIView*yourView

在viewDidLoad中输入:

actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                             delegate:self
                             cancelButtonTitle:@"Cancel"
                             destructiveButtonTitle:@"Delete Note"
                             otherButtonTitles:@"Call",@"Add a Contact",nil];

[yourView = self.view]
要通过iAction的某个声明按钮启动菜单,您需要:

-(IBAction)viewMapButton:(id) sender
{
    [actionSheet showInView:yourView];

}
要根据用户选择采取适当的操作,请声明以下方法并检查
[actionSheet ButtonTitleIndex:buttonIndex]
等于:

- (void)actionSheet:(UIActionSheet *)actionSheet
        clickedButtonAtIndex:(NSInteger)buttonIndex
        {
        NSString * what_action = [actionSheet buttonTitleAtIndex:buttonIndex];
        NSLog(@"The %@ button was tapped.", what_action);
             if ([what_action isEqualToString:@"Call"])
                 {
                 NSString *phoneNumber = [[NSString alloc] 
                        initWithString:@"telprompt:1234567890"];
                 [[UIApplication sharedApplication] 
                        openURL:[NSURL URLWithString:phoneNumber]];
                 }
}
[注意:在iOS模拟器上启动呼叫不起作用]