gpt4 book ai didi

ios - 具有许多项目的 UIActionSheet 覆盖文本

转载 作者:行者123 更新时间:2023-11-28 17:53:20 24 4
gpt4 key购买 nike

我们有一个包含许多选项的 UIActionSheet。在 iPad 上的 iOS 7 中滚动列表时,它会重影原始值。这是 iPad 7 的错误还是我们可以做出改变? iOS 6 iPad 和 iPhone 在我们看来还不错。

before scrolling

after scrolling

//
// ViewController.m
// AlertViewTest
//
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

_data = [NSMutableArray new];
[_data addObject:@"Arthur"];
[_data addObject:@"Bertha"];
[_data addObject:@"Cristobal"];
[_data addObject:@"Dolly"];
[_data addObject:@"Edouard"];
[_data addObject:@"Fay"];
[_data addObject:@"Gonzalo"];
[_data addObject:@"Hanna"];
[_data addObject:@"Isaias"];
[_data addObject:@"Josephine"];
[_data addObject:@"Kyle"];
[_data addObject:@"Laura"];
[_data addObject:@"Marco"];
[_data addObject:@"Nana"];
[_data addObject:@"Omar"];
[_data addObject:@"Paulette"];
[_data addObject:@"Rene"];
[_data addObject:@"Sally"];
[_data addObject:@"Teddy"];
[_data addObject:@"Vicky"];
[_data addObject:@"Wilfred"];

[_data addObject:@"Ana"];
[_data addObject:@"Bill"];
[_data addObject:@"Claudette"];
[_data addObject:@"Danny"];
[_data addObject:@"Erika"];
[_data addObject:@"Fred"];
[_data addObject:@"Grace"];
[_data addObject:@"Henri"];
[_data addObject:@"Ida"];
[_data addObject:@"Joaquin"];
[_data addObject:@"Kate"];
[_data addObject:@"Larry"];
[_data addObject:@"Mindy"];
[_data addObject:@"Nicholas"];
[_data addObject:@"Odette"];
[_data addObject:@"Peter"];
[_data addObject:@"Rose"];
[_data addObject:@"Sam"];
[_data addObject:@"Teresa"];
[_data addObject:@"Victor"];
[_data addObject:@"Wanda"];

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)showAlert:(id)sender {
if([self.actionSheet isVisible]) {
[self.actionSheet dismissWithClickedButtonIndex:[self.actionSheet cancelButtonIndex] animated:YES];

self.actionSheet.delegate = nil;
self.actionSheet = nil;

return;
}

if(nil == self.actionSheet) {
self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select one"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];


if(![self shouldPresentActionSheet:self.actionSheet]) {
self.actionSheet = nil;
return;
}


[self.actionSheet setCancelButtonIndex:[self.actionSheet addButtonWithTitle:NSLocalizedString(@"Cancel", @"Cancel")]];

}

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.actionSheet showFromBarButtonItem:self.button animated:YES];
} else {
[self.actionSheet showFromToolbar:self.toolbar];
}
}

-(BOOL)shouldPresentActionSheet:(UIActionSheet *)actionSheet
{
if(actionSheet == self.actionSheet) {
if([self.data count] == 0) {
return NO;
}
for(NSString *d in self.data) {
[self.actionSheet addButtonWithTitle:d];
}

}
return YES;
}

@end

最佳答案

@Flores在评论中是正确的,这是解决此问题的方法:

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
actionSheet.backgroundColor = [UIColor whiteColor];
for (UIView *subview in actionSheet.subviews) {
subview.backgroundColor = [UIColor whiteColor];
}
}

关于ios - 具有许多项目的 UIActionSheet 覆盖文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23792589/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com