滑动到新笔尖

发布于 2024-12-11 02:56:08 字数 555 浏览 0 评论 0原文

我只是想能够滑动到新的笔尖,但我被卡住了。我的代码构建正确,没有错误或警告,但没有任何反应。

这是我的代码

- (IBAction) handleSwipeGesture:(UIGestureRecognizer *) sener { 
        NSLog(@"swipe left");
    if(UISwipeGestureRecognizerDirectionLeft) {
        SecondDetailViewController *tempController = [[SecondDetailViewController alloc] 
         initWithNibName:@"SecondDetailView" 
          bundle:nil];
        newController = [tempController retain];
        [tempController release];
    }

}

系统看到我正在滑动(它被记录)但它不会转到新的笔尖。 我并没有真正与我的代码结婚,所以如果我需要完全重写它我没问题。

I just want to be able to swipe to a new nib, but am getting stuck. My code builds properly with no errors or warnings, but nothing happens.

Here is my code

- (IBAction) handleSwipeGesture:(UIGestureRecognizer *) sener { 
        NSLog(@"swipe left");
    if(UISwipeGestureRecognizerDirectionLeft) {
        SecondDetailViewController *tempController = [[SecondDetailViewController alloc] 
         initWithNibName:@"SecondDetailView" 
          bundle:nil];
        newController = [tempController retain];
        [tempController release];
    }

}

The system sees that I am swiping (it gets logged) but it doesn't go to the new nib.
I'm not really married to my code, so if I need to completely rewrite this I'm OK.

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

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

发布评论

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

评论(2

睫毛溺水了 2024-12-18 02:56:08

假设您正在视图控制器内处理滑动手势(并且您正在使用导航控制器),您应该执行如下操作:

- (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)sender { 
    if(sender.direction == UISwipeGestureRecognizerDirectionLeft) {
        NSLog(@"swipe left");
        SecondDetailViewController *tempController = [[SecondDetailViewController alloc]
                                  initWithNibName:@"SecondDetailView" bundle:nil];
        [self.navigationController pushViewController:tempController animated:YES];
        [tempController release];
    }
}

此行将 tempController 推到导航控制器顶部:

[self.navigationController pushViewController:tempController animated:YES];

如果您想呈现tempController 模态上,你应该调用它:

[self presentModalViewController:tempController animated:YES];

Assuming you're handling swipe gesture inside a view controller (and you are using navigation controller), you should do something like this:

- (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)sender { 
    if(sender.direction == UISwipeGestureRecognizerDirectionLeft) {
        NSLog(@"swipe left");
        SecondDetailViewController *tempController = [[SecondDetailViewController alloc]
                                  initWithNibName:@"SecondDetailView" bundle:nil];
        [self.navigationController pushViewController:tempController animated:YES];
        [tempController release];
    }
}

This line pushes tempController on top of the navigation controller:

[self.navigationController pushViewController:tempController animated:YES];

if you want to present tempController modally, you should call this instead:

[self presentModalViewController:tempController animated:YES];
归属感 2024-12-18 02:56:08

创建 newController 对象后,您不会对其执行任何操作。您需要将其推送到导航控制器上,以模态方式呈现,或者抓取视图并将其放在屏幕上。

You are not doing anything with the newController object after you create it. You need to either push it onto your nav controller, present it modally, or grab the view and put it on the screen.

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