UIPopOver 中如何提供按钮选择?

发布于 2024-12-18 09:49:41 字数 1241 浏览 4 评论 0原文

- (IBAction)openImagePicker:(id)sender //Makes UIImagePicker roll up from the bottom.
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        // We are using an iPhone
        UIActionSheet *alertSheet = [[UIActionSheet alloc] initWithTitle:@"Where do you want to get your daily image?" delegate:(self) cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Library", nil];
        [alertSheet setTag:0];
        [alertSheet setDelegate:self];
        [alertSheet showFromTabBar:[[self tabBarController] tabBar]];
        [alertSheet release];
    }
    else
    {
        // We are using an iPad
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = self;
        UIPopoverController *popoverController=[[UIPopoverController alloc] initWithContentViewController:imagePickerController];
        popoverController.delegate=self;
        [popoverController presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
}

因此,在 iPad 部分,我希望它能够让你在拍摄新照片和使用已有照片之间做出选择,就像在 iPhone 上一样。现在它可以让你选择你已经拿过的一个。

- (IBAction)openImagePicker:(id)sender //Makes UIImagePicker roll up from the bottom.
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        // We are using an iPhone
        UIActionSheet *alertSheet = [[UIActionSheet alloc] initWithTitle:@"Where do you want to get your daily image?" delegate:(self) cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Library", nil];
        [alertSheet setTag:0];
        [alertSheet setDelegate:self];
        [alertSheet showFromTabBar:[[self tabBarController] tabBar]];
        [alertSheet release];
    }
    else
    {
        // We are using an iPad
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = self;
        UIPopoverController *popoverController=[[UIPopoverController alloc] initWithContentViewController:imagePickerController];
        popoverController.delegate=self;
        [popoverController presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
}

So where it does the iPad part, what I want it to do is give you a choice between taking a new picture, and using one you already have, just like it does on the iPhone. Right now all it lets you do it choose one you already took.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

站稳脚跟 2024-12-25 09:49:41

UIActionSheet 有一个名为 showFromBarButtonItem:animated: 的方法。如果您指定栏按钮项目,则操作表将显示在 iPad 上的弹出窗口中。

UIActionSheet has a method called showFromBarButtonItem: animated:. If you specify a bar button item, the action sheet will display in a popover on the iPad.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文