0

嗨,我目前有一个带有导航控制器的基于导航的应用程序,在应用程序内有许多视图,并推回显示不同的 xib,我想做的是在屏幕右下角显示一个固定在屏幕上的按钮,它轻按时会将用户带到帮助 xib,

但是,当我每次按下或弹出视图时,按钮正在被动画化并移动到位,我希望按钮在被按下和弹出时不要移动并保持在视图的顶部。

想知道是否有人可以帮助我,谢谢,萨米。

4

2 回答 2

0

在创建 UIButton 中创建一个 UIView 类,并在所有视图控制器中创建该视图的对象,并将其添加到 self.view。

于 2012-07-17T12:59:02.213 回答
0

在 appdelegate 中使用它将帮助您在所有屏幕上显示按钮。如果您需要处理此按钮,请将 viewcontrollerAppdelegate.h 导入视图控制器。并使用

UIAppDelegate.SettingButton.hidden=True;

或像这样任何。试试看嘛

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {

        settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [settingButton addTarget:self action:@selector(settingButtonPressed:)forControlEvents:UIControlEventTouchDown];
        UIImage *buttonImage = [UIImage imageNamed:@"icon-lb.png"];
        [settingButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
        [settingButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        settingButton.frame = CGRectMake(265, 17, 40, 45);
        settingButton.hidden=TRUE;
        [self.window addSubview:settingButton];
        [self.window makeKeyAndVisible];
        return YES;
    }


    - (void)settingButtonPressed:(id) sender {
         [[NSNotificationCenter defaultCenter] postNotificationName:@"settingButtonPressed" object:nil];
        setting *obj = [[setting alloc] initWithNibName:@"setting" bundle:nil];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:obj];
        navController.navigationBar.tintColor=[UIColor blackColor];  
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5]; 
        [self.window addSubview:navController.view];
        [navController.view setFrame:CGRectMake(0,480,320,480)];
            [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:navController.view cache:YES];
        [navController.view setFrame:CGRectMake(0,0,320,480)];
        [UIView commitAnimations];    

    }
于 2012-08-02T12:15:22.933 回答