作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
想知道在选项卡按钮中显示操作表后如何调用segue。
如果 appdelegate 不是一个好的地方,我在应用程序委托(delegate)中完成了所有这些操作。我应该将这些代码行添加到哪里?
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
NSInteger choice = 1; // --> index of the view controller that should "act as button"
if (viewController == [tabBarController.viewControllers objectAtIndex:choice])
{
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:Nil
otherButtonTitles:@"000", @"Car Accident",@"Home",@"Property", nil];
sheet.tag = 0;
sheet.title=@"test";
NSLog(@"tab tab");
[sheet showInView:self.window];
return NO;
}
NSLog(@"YES YES");
return YES;
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(actionSheet.tag == 0)
{
if (buttonIndex == 0)
{
UIDevice *device = [UIDevice currentDevice];
if ([[device model] isEqualToString:@"iPhone"])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt:000"]];
} else
{
UIAlertView *Notpermitted=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[Notpermitted show];
}
}
else if (buttonIndex == 1)
{
NSLog(@"Car Accident");
//tried to call a segue here.
}
else if (buttonIndex == 2)
{
NSLog(@"YES YES");
}
else if (buttonIndex == 3)
{
NSLog(@"YES YES");
}
}
}
感谢您的阅读和评论。
最佳答案
- (void)viewDidLoad
{
[super viewDidLoad];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
// Do any additional setup after loading the view.
UITabBarController *tabController = (UITabBarController *)appDelegate.window.rootViewController;
tabController.selectedIndex = 0;
tabController.delegate = self;
}
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
NSInteger choice = 1; // --> index of the view controller that should "act as button"
if (viewController == [tabBarController.viewControllers objectAtIndex:choice])
{
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:Nil
otherButtonTitles:@"000", @"Car Accident",@"Home",@"Property", nil];
sheet.tag = 0;
sheet.title=@"Emergency";
NSLog(@"tab tab");
[sheet showInView:[self.view superview]];
return NO;
}
NSLog(@"YES YES");
return YES;
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(actionSheet.tag == 0)
{
if (buttonIndex == 0)
{
UIDevice *device = [UIDevice currentDevice];
if ([[device model] isEqualToString:@"iPhone"])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt:000"]];
} else
{
UIAlertView *Notpermitted=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[Notpermitted show];
}
}
else if (buttonIndex == 1)
{
NSLog(@"Car Accident");
[self performSegueWithIdentifier:@"pushToCarView" sender:self];
}
else if (buttonIndex == 2)
{
NSLog(@"YES YES");
}
else if (buttonIndex == 3)
{
NSLog(@"YES YES");
}
}
}
关于iphone - 如何在 tabbarbutton 中点击 uiactionsheet 后调用 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11666233/
想知道在选项卡按钮中显示操作表后如何调用segue。 如果 appdelegate 不是一个好的地方,我在应用程序委托(delegate)中完成了所有这些操作。我应该将这些代码行添加到哪里? - (B
我是一名优秀的程序员,十分优秀!