【问题标题】:How to create UIActionSheet or UIAlertController(UIAlertControllerStyleActionSheet) like Apple Music?如何像 Apple Music 一样创建 UIActionSheet 或 UIAlertController(UIAlertControllerStyleActionSheet)?
【发布时间】:2016-01-23 11:39:18
【问题描述】:

在我的应用中,我想创建一个 UIActionSheetUIAlertController (UIAlertControllerStyleActionSheet) 就像 Apple Music。

我想在UIActionSheet 的第一行和普通UIActionSheet 的其他选项中显示用户个人资料图片和用户的一些基本详细信息。

【问题讨论】:

  • 好的,你为实现这个目标做了什么?请显示您当前的设置,您尝试在自定义视图中显示您想要显示的所有数据。
  • 到目前为止,我正在做的是自定义 UIViewControllers,我在其中设置了代表和其他东西。当前的 Apple SDK 没有关于他们如何做到这一点的提示

标签: ios objective-c uiactionsheet uialertcontroller


【解决方案1】:

在某种程度上,我可以为您提供问题的示例编码

UIAlertController *alertMusicVideos =   [UIAlertController
                             alertControllerWithTitle:@"Music Videos"
                             message:nil
                             preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *actionAddProfilePhoto = [UIAlertAction
                     actionWithTitle:@""
                     style:UIAlertActionStyleDefault
                     handler:^(UIAlertAction * action)
                     {
                         //Do Whatever you want to do here 
                         [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                     }];

UIAlertAction *actionPlayNext = [UIAlertAction
                     actionWithTitle:@"Play Next"
                     style:UIAlertActionStyleDefault
                     handler:^(UIAlertAction * action)
                     {
                         //Do some thing here
                         [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                     }];
UIAlertAction *actionAddToUpNext = [UIAlertAction
                         actionWithTitle:@"Add to Up Next"
                         style:UIAlertActionStyleDefault
                         handler:^(UIAlertAction * action)
                         {
                             //Do Whatever you want to do here when click this button
                             [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                         }];
UIAlertAction *actionAddToPlayList = [UIAlertAction
                         actionWithTitle:@"Add To PlayList"
                         style:UIAlertActionStyleDefault
                         handler:^(UIAlertAction * action)
                         {
                              //Do Whatever you want to do here when click this button
                             [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                         }];
UIAlertAction *actionDeleteFromMyMusic = [UIAlertAction
                               actionWithTitle:@"Delete From My Music"
                               style:UIAlertActionStyleDestructive
                               handler:^(UIAlertAction * action)
                               {
                                    //Do Whatever you want to do here when click this button
                                   [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                               }];

 UIAlertAction *actionCancel = [UIAlertAction
                               actionWithTitle:@"Cancel"
                               style:UIAlertActionStyleDestructive
                               handler:^(UIAlertAction * action)
                               {
                                    //Do Whatever you want to do here when click this button
                                   [alertMusicVideos dismissViewControllerAnimated:YES completion:nil];

                               }];

[actionAddProfilePhoto setValue:[[UIImage imageNamed:@"yourProfile.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];

[alertMusicVideos addAction:actionAddProfilePhoto];
[alertMusicVideos addAction:actionPlayNext];
[alertMusicVideos addAction:actionAddToUpNext];
[alertMusicVideos addAction:actionAddToPlayList];
[alertMusicVideos addAction:actionDeleteFromMyMusic];
[alertMusicVideos addAction:actionCancel];

[self presentViewController:alertMusicVideos animated:YES completion:nil];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-14
    • 1970-01-01
    • 1970-01-01
    • 2022-08-07
    • 2018-10-27
    • 2018-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多