gpt4 book ai didi

ios - 导航栏在显示 AlertViewController 后更改我的项目位置

转载 作者:行者123 更新时间:2023-11-29 01:52:59 24 4
gpt4 key购买 nike

我的导航栏上有 2 个图标,但是当我显示 alertViewController 时,这些图标会改变它们的位置。

那些是我的图标。

enter image description here

当我显示 alertViewController

时会发生这种情况

enter image description here

这是我的 viewController 内容。

UIBarButtonItem *helpItem;
UIBarButtonItem *helpItem1;

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

[self setup];
}

-(void)setup{
helpItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(helpButtonItemTapped:)];

helpItem1 = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(helpButtonItemTapped:)];

helpItem.image = [UIImage imageNamed:@"test"];

helpItem1.image = [UIImage imageNamed:@"test"];

self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects: helpItem, helpItem1, nil];
}

-(void)helpButtonItemTapped:(id)sender{
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@"Title"
message:nil
preferredStyle:UIAlertControllerStyleActionSheet
];

[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
]];

[self presentViewController:alertController animated:YES completion:nil];
}

最佳答案

将您的初始 UIBarbuttonItem 代码更改为此

 helpItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"memoAccess"] style: UIBarButtonItemStylePlain target:self action:@selector(helpButtonItemTapped:)];
helpItem1 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"memoAccess"] style: UIBarButtonItemStylePlain target:self action:@selector(helpButtonItemTapped:)];

截图

enter image description here

关于ios - 导航栏在显示 AlertViewController 后更改我的项目位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31209477/

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