【问题标题】:Duplicating Twitterrific Style Alert复制 Twitterrific 样式警报
【发布时间】:2013-06-30 21:52:35
【问题描述】:

我正在尝试复制中间的屏幕,即为撰写新推文而显示的警报。我试图用自定义的UIAlertView 复制它,但这需要大量的子类化而不是什么,然后我怀疑它可能只是一个简单的UIViewController 显示在主视图上......来自 iOS 同胞的专业想法需要开发人员。

谢谢。

【问题讨论】:

  • 中间的屏幕?它不是 UIAlertView... 它应该是自定义 UIView。好吧,如果是发推文,你应该使用 iOS SDK 中的 Twitter API 吗?
  • 不,我将它用于其他用途,是的,我认为它会是一个 UIView,但你知道如何实现它吗?

标签: iphone ios uiviewcontroller uialertview uistoryboard


【解决方案1】:

在 iPad 中:

您可以通过UIViewController 来完成。

  • 您需要根据上图设计UI。
  • 然后你需要将Modal Presentation Style设置为UIModalPresentationFormSheet
  • 并使用- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void)) 呈现它

喜欢:

UIViewController *viewC = [[UIViewController alloc] init];
viewC.view.frame = //set the frame;
viewC.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:viewC animated:YES completion:nil];

在 iPhone 中:

您可以使用UIView 来做到这一点。

您可以使用以下代码来执行此操作:

在你的界面中声明一个属性

@property (nonatomic, strong) UIView *views;

//添加视图

- (void) showView
{
   UIToolbar *toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 35)];
        UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(remove)];
        toolbar.items = [NSArray arrayWithObject:bar];
        _views = [[UIView alloc] initWithFrame:CGRectMake(0, -300, self.view.bounds.size.width, self.view.bounds.size.height/3)];
        [_views addSubview:toolbar];
        [_views setBackgroundColor:[UIColor grayColor]];
        [self.view addSubview:_views];
        [UIView animateWithDuration:0.7
                              delay:0.0
                            options:UIViewAnimationCurveLinear
                         animations:^{

                             _views.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height/3);
                         }
                         completion:^(BOOL yes){
                             NSLog(@"YO");

                         }];
        [UIView commitAnimations];
}

//移除视图

- (void)remove
{
    [UIView animateWithDuration:0.7
                          delay:0.0
                        options:UIViewAnimationCurveLinear
                     animations:^{
                         _views.frame = CGRectMake(0, -500, self.view.bounds.size.width, self.view.bounds.size.height/3);
                     }
                     completion:^(BOOL yes){
                         NSLog(@"YA");

                     }];
    [UIView commitAnimations];
}

【讨论】:

  • 我摆弄了视图控制器的框架,但它总是显示在整个视图上,而不是作为主视图控制器的覆盖显示。
  • @Ravin455:你设置框架了吗?
  • @Ravin455:检查样式here
  • 我认为这只适用于 iPad。我发现了这个:stackoverflow.com/questions/3702653/… 不过,我认为这是我问题的答案。
  • @Ravin455:您需要在界面中声明一个属性,例如:@property (nonatomic, strong) UIView *views;
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-17
相关资源
最近更新 更多