通过 TabBar 调情两个视图

发布于 2024-12-01 16:53:26 字数 1374 浏览 2 评论 0原文

这是我的代码:

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIBarButtonItem *newButton = [[UIBarButtonItem alloc] 
                              initWithTitle:@"Speichern" 
                              style:UIBarButtonItemStylePlain target:self 
                              action:@selector(SaveSettings)]; 
self.navigationItem.rightBarButtonItem = newButton; 
[newButton release]; 

ensStyleControl.selectedSegmentIndex = [SettingsHandler GetENSStyle];

UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 376, 320, 44)];
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:@"Allgemein" image:[UIImage imageNamed:@"crops.png"] tag:0];
UITabBarItem *item2  = [[UITabBarItem alloc] initWithTitle:@"ENS" image:[UIImage imageNamed:@"crops.png"] tag:1];

[item1 performSelectorOnMainThread:@selector(ShowGeneralSetting) withObject:nil waitUntilDone:NO];

[item2 performSelectorOnMainThread:@selector(ShowENSSetting) withObject:nil waitUntilDone:NO];


NSArray *items = [NSArray arrayWithObjects:item1,item2, nil];
[tabBar setItems:items animated:YES];
[tabBar setSelectedItem:nil];
tabBar.delegate=self;

[self.view addSubview:tabBar];
}

- (void)ShowENSSetting
{
    //Show View1
}

- (void)ShowGeneralSetting
{
    //Show View2
}

如何在方法中在 View1 和 View2 之间翻转?

this is my code:

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIBarButtonItem *newButton = [[UIBarButtonItem alloc] 
                              initWithTitle:@"Speichern" 
                              style:UIBarButtonItemStylePlain target:self 
                              action:@selector(SaveSettings)]; 
self.navigationItem.rightBarButtonItem = newButton; 
[newButton release]; 

ensStyleControl.selectedSegmentIndex = [SettingsHandler GetENSStyle];

UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 376, 320, 44)];
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:@"Allgemein" image:[UIImage imageNamed:@"crops.png"] tag:0];
UITabBarItem *item2  = [[UITabBarItem alloc] initWithTitle:@"ENS" image:[UIImage imageNamed:@"crops.png"] tag:1];

[item1 performSelectorOnMainThread:@selector(ShowGeneralSetting) withObject:nil waitUntilDone:NO];

[item2 performSelectorOnMainThread:@selector(ShowENSSetting) withObject:nil waitUntilDone:NO];


NSArray *items = [NSArray arrayWithObjects:item1,item2, nil];
[tabBar setItems:items animated:YES];
[tabBar setSelectedItem:nil];
tabBar.delegate=self;

[self.view addSubview:tabBar];
}

- (void)ShowENSSetting
{
    //Show View1
}

- (void)ShowGeneralSetting
{
    //Show View2
}

How to Flip between View1 and View2 in the Methods?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狼性发作 2024-12-08 16:53:26
- (void)ShowENSSetting{
//assume    view1.tag=11;
    [UIView transitionWithView:self.view duration:2.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^(void) {

        if (![self.view viewWithTag:11]) {
            view1.tag=11;
            [self.view addSubview:view1];

        }

        else {
            [self.view bringSubviewToFront:[self.view viewWithTag:11]];
        }




    } completion:^(BOOL finished) {

        NSLog(@"ENSSetting active");

    }];




}


- (void)ShowGeneralSetting{

        //assume    view2.tag=22;

    [UIView transitionWithView:self.view duration:2.0 options:UIViewAnimationOptionTransitionFlipFromRight animations:^(void) {

        if (![self.view viewWithTag:22]) {
            view2.tag=22;               
            [self.view addSubview:view2];

        }

        else {
            [self.view bringSubviewToFront:[self.view viewWithTag:22]];
        }




    } completion:^(BOOL finished) {

        NSLog(@"GeneralSetting active");

    }];





}
- (void)ShowENSSetting{
//assume    view1.tag=11;
    [UIView transitionWithView:self.view duration:2.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^(void) {

        if (![self.view viewWithTag:11]) {
            view1.tag=11;
            [self.view addSubview:view1];

        }

        else {
            [self.view bringSubviewToFront:[self.view viewWithTag:11]];
        }




    } completion:^(BOOL finished) {

        NSLog(@"ENSSetting active");

    }];




}


- (void)ShowGeneralSetting{

        //assume    view2.tag=22;

    [UIView transitionWithView:self.view duration:2.0 options:UIViewAnimationOptionTransitionFlipFromRight animations:^(void) {

        if (![self.view viewWithTag:22]) {
            view2.tag=22;               
            [self.view addSubview:view2];

        }

        else {
            [self.view bringSubviewToFront:[self.view viewWithTag:22]];
        }




    } completion:^(BOOL finished) {

        NSLog(@"GeneralSetting active");

    }];





}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文