【问题标题】:progressview is not getting displayed in ios7ios7中没有显示进度视图
【发布时间】:2013-10-04 12:43:54
【问题描述】:

我通过将进度视图和标签作为子视图添加到警报视图来显示进度视图和标签,这在 IOS6 上运行良好,我在 IOS7 上测试了相同的东西,但进度视图和标签没有显示。下面是我的代码。需要进行哪些更改才能使其在 ios7 上运行?

 alert = [[UIAlertView alloc] initWithTitle:@"Please Wait..Downloading reports..."    message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] ;
alert.frame=CGRectMake(50, 50, 280, 40);
prgView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar];
prgView.frame = CGRectMake(10, 60, 265, 20);
prgView.hidden=NO;
[alert addSubview:prgView];
statusLabel = [[UILabel alloc] init];
statusLabel.backgroundColor = [UIColor clearColor];
statusLabel.textColor = [UIColor whiteColor];
statusLabel.font = [UIFont fontWithName:@"AmericanTypewriter-Condensed" size:18.0];
statusLabel.frame = CGRectMake(120, 80, 80, 20);
[alert addSubview:statusLabel];
[alert show];

【问题讨论】:

  • iOS7 不允许在UIAlertViewUIActonSheet 中添加任何子视图,你应该另想办法。
  • 哦..好的..谢谢holex..你知道这背后的原因吗?
  • 我认为这与用户隐私有关,因为许多应用程序都做到了:在没有用户明确意愿的情况下,他们自动选择了这个或那个选项(不仅在 UIAlertView 中),这并不是真的公平的行为在 IAP 的情况下;所以我猜他们喜欢限制对系统相关控件的访问,这将是程序的开始。
  • @RockandRoll 你有没有找到解决这个问题的方法?

标签: ios ios7 uiprogressview


【解决方案1】:

尝试使用showInView 而不是addSubview

[alert showInView:self.view];

【讨论】:

  • 我在UIAlertView中没有找到“ShowInView”方法,你是怎么做到的?
【解决方案2】:

与 OP 略有不同,为通过搜索找到此内容的人添加。 在我的情况下, UIProgressBar 被添加到 UIView 没有指定 Y 偏移量。在 iOS6 下这显示在导航栏下方,但在 iOS7 下进度条在导航栏后面。我通过将进度条框架 Y 设置为导航栏的 Y + 高度来解决问题,如下所示:

CGRect navframe = [[self.navigationController navigationBar] frame];
CGFloat yloc = (navframe.size.height + navframe.origin.y);

UIProgressView *progressBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar ];
CGRect pbFrame = progressBar.frame;
CGRect vFrame = self.view.frame;
pbFrame.size.width = vFrame.size.width;
pbFrame.origin.y = yloc;
progressBar.frame = pbFrame;

[self.view addSubview:progressBar];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-15
    相关资源
    最近更新 更多