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