gpt4 book ai didi

ios - 使用 UIActionSheet 更改 View 时工具栏项目消失

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:23:49 26 4
gpt4 key购买 nike

UIActionSheet 启动 View 时按钮,通过 navigationBar 后退按钮返回 View 时,工具栏虽然仍然可见,但没有任何以前在其上的按钮。此错误自更新到 iOS 6 后出现,并在模拟器和仅运行 iOS 6 的设备上进行测试时发生。如果我在 UIActionSheet 推送的 View 上注释掉隐藏工具栏的代码返回时添加按钮。

我在 viewWillAppear 中以编程方式制作我的工具栏项并显示 UIActionSheet从我通过 self.navigationController.toolbar 访问的工具栏.

知道是什么导致了这个问题吗?这只是在 iOS 6 出现后才发生的,所以关于 viewWillAppear 是否有任何我需要考虑的变化? ?

这是从 actionSheet 推送 View 的方式:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

if (actionSheet.tag == 2) {

if (buttonIndex == 0) {

[self dismissAllTips];

self.actionNoteAddView= [[self.storyboard instantiateViewControllerWithIdentifier:@"IDActionNoteAddView"] retain];

actionNoteAddView.note_id = 0;
actionNoteAddView.iscompleted=0;

[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"tool_tips"];

[self.navigationController pushViewController:actionNoteAddView animated:TRUE];

[actionNoteAddView release];

}else if(buttonIndex == 1){

...

这些是推送 View 的 View 方法:

-(void)viewWillAppear:(BOOL)animated{

[super viewWillAppear:animated];

self.navigationItem.hidesBackButton = NO;
[self.navigationController setToolbarHidden:YES];

txtcontent.layer.cornerRadius = 10.0f;

}


-(void)viewDidAppear:(BOOL)animated{

[super viewDidAppear:animated];

}

这些是使用 actionSheet 推送 View 的 View 的 View 方法:

- (void) viewWillAppear:(BOOL)animated{

[super viewWillAppear:animated];

self.navigationItem.hidesBackButton = YES;
[self.navigationController setToolbarHidden:NO];
self.navigationController.navigationBarHidden=NO;

self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.8 green:0.45 blue:0.2 alpha:1];
self.navigationController.toolbar.barStyle = UIBarStyleBlackOpaque;
self.navigationController.toolbar.tintColor = [UIColor colorWithRed:0.8 green:0.45 blue:0.2 alpha:1];

UIImage *actionButtonImage = [UIImage imageNamed:@"31-circle-plus@2x.png"];
UIBarButtonItem *actionButton = [[UIBarButtonItem alloc] initWithImage:actionButtonImage style:UIBarButtonItemStylePlain target:self action:@selector(actionPressed:)
];

UIImage *dashButtonImage = [UIImage imageNamed:@"19-gear.png"];
UIBarButtonItem *dashButton = [[UIBarButtonItem alloc] initWithImage:dashButtonImage style:UIBarButtonItemStylePlain target:self action:@selector(settingsPressed:)];




UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];

NSArray *toolitems = [NSArray arrayWithObjects:dashButton, flexItem, actionButton, flexItem, nil];

[self setToolbarItems:toolitems];

self.title = @"Dashboard";

defaultProfile.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"default_profile"];

BOOL dailyProcess = [[NSUserDefaults standardUserDefaults] boolForKey:@"daily_process"];

if(dailyProcess){

[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"daily_process"];
[[NSUserDefaults standardUserDefaults] synchronize];

loading = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

labelProcess = [[UILabel alloc]initWithFrame:CGRectMake(60, 105, 240, 30)];
labelProcess.text = @"Processing...";
labelProcess.backgroundColor = [UIColor clearColor];
labelProcess.textColor=[UIColor colorWithRed:0.8 green:0.45 blue:0.2 alpha:1];
[labelProcess setFont:[UIFont systemFontOfSize:20]];

loading.opaque = NO;
loading.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.6f];

indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[indicator setHidesWhenStopped:YES];
indicator.center = self.view.center;

[self.view addSubview:loading];
[self.view addSubview:indicator];

[self.view addSubview:labelProcess];

[indicator startAnimating];

}

}


-(void)viewDidAppear:(BOOL)animated{

[super viewDidAppear:animated];

CGRect frame = CGRectMake(157, 365, 10, 10);
UIView *viewToPointAt = [[UIView alloc] initWithFrame:frame];

[self.view addSubview:viewToPointAt];

BOOL willies = [[NSUserDefaults standardUserDefaults] boolForKey:@"tool_tips"];

if(willies==YES){

if(popTip == nil) {

popTip = [[[CMPopTipView alloc] initWithMessage:@"Step 1/3: This is the Action Button. You can create, view and auto-fill notes which are then added to your timeline.(Click for step 2)."] autorelease];
popTip.delegate = self;

[popTip presentPointingAtView:viewToPointAt inView:self.view animated:YES];
popTip.backgroundColor = [UIColor colorWithRed:0.8 green:0.45 blue:0.2 alpha:1];
popTip.textColor = [UIColor whiteColor];

}

}

[viewToPointAt release];

}

最佳答案

尝试了很多不同的技术并最终通过在一种 View 方法中显示它并在下一种 View 方法中隐藏它来对其进行排序。这是我遇到的最奇怪的错误之一,这很难解决,但我讨厌没有答案的问题。

关于ios - 使用 UIActionSheet 更改 View 时工具栏项目消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13031608/

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