首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

#popover

UIPopover如何用这样的按钮制作一个popover ?

工口Miku说唱歌手
类似于其他的回应,但这是很容易实现的比较。 使您的类使用UIActionSheetDelegate。 例子: @interface ExampleViewController : UIViewController <UIActionSheetDelegate> 然后添加到ExampleViewController.mm/m中 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { //Get the name of the current pressed button NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex]; if ([buttonTitle isEqualToString:@"Remove"]) { NSLog(@"Remove this actionSheet"); } if ([buttonTitle isEqualToString:@"Button 1"]) { NSLog(@"Button 1 pressed"); } if ([buttonTitle isEqualToString:@"Button 2"]) { NSLog(@"Button 2 pressed"); } if ([buttonTitle isEqualToString:@"Button 3"]) { NSLog(@"Button 3 pressed"); } if ([buttonTitle isEqualToString:@"Cancel"]) { NSLog(@"Cancel clicked (anywhere away from it)"); } } 现在,在按钮按下的事件中,或者在需要弹出事件的位置/时间,请调用以下命令: - (IBAction)aButtonPressed:(id)sender { NSString *actionSheetTitle = @"Action Sheet"; // Title NSString *destroyTitle = @"Destroy"; // Button titles NSString *button1 = @"Button 1"; NSString *button2 = @"Button 2"; NSString *button3 = @"Button 3"; NSString *cancelTitle = @"Cancel"; UIActionSheet *actionSheet = [[UIActionSheet alloc]                               initWithTitle:actionSheetTitle                               delegate:self                                cancelButtonTitle:cancelTitle                              destructiveButtonTitle:destroyTitle                               otherButtonTitles:button1, button2, button3, nil]; [actionSheet showInView:self.view]; } 更多有关这方面的信息:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html ... 展开详请
类似于其他的回应,但这是很容易实现的比较。 使您的类使用UIActionSheetDelegate。 例子: @interface ExampleViewController : UIViewController <UIActionSheetDelegate> 然后添加到ExampleViewController.mm/m中 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { //Get the name of the current pressed button NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex]; if ([buttonTitle isEqualToString:@"Remove"]) { NSLog(@"Remove this actionSheet"); } if ([buttonTitle isEqualToString:@"Button 1"]) { NSLog(@"Button 1 pressed"); } if ([buttonTitle isEqualToString:@"Button 2"]) { NSLog(@"Button 2 pressed"); } if ([buttonTitle isEqualToString:@"Button 3"]) { NSLog(@"Button 3 pressed"); } if ([buttonTitle isEqualToString:@"Cancel"]) { NSLog(@"Cancel clicked (anywhere away from it)"); } } 现在,在按钮按下的事件中,或者在需要弹出事件的位置/时间,请调用以下命令: - (IBAction)aButtonPressed:(id)sender { NSString *actionSheetTitle = @"Action Sheet"; // Title NSString *destroyTitle = @"Destroy"; // Button titles NSString *button1 = @"Button 1"; NSString *button2 = @"Button 2"; NSString *button3 = @"Button 3"; NSString *cancelTitle = @"Cancel"; UIActionSheet *actionSheet = [[UIActionSheet alloc]                               initWithTitle:actionSheetTitle                               delegate:self                                cancelButtonTitle:cancelTitle                              destructiveButtonTitle:destroyTitle                               otherButtonTitles:button1, button2, button3, nil]; [actionSheet showInView:self.view]; } 更多有关这方面的信息:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html
领券