【问题标题】:Problem with info view on iPhone appiPhone应用程序上的信息视图问题
【发布时间】:2010-11-23 00:21:17
【问题描述】:

我目前正在使用此代码为 iPhone 应用程序调出信息视图。

-(IBAction)showInfo:(id)sender {
InfoView *info = [[InfoView alloc] initWithNibName:nil bundle:[NSBundle mainBundle]];
info.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:info animated:YES];
[info release];

}

这段代码回到我的主视图

-(IBAction) exitInfo:(id)sender {
 [self.parentViewController dismissModalViewControllerAnimated: YES];
}

当我在模拟器上运行它时,它运行良好,但是,在实际的 iPhone 上,当我按下触发 exitInfo 方法的按钮时,它会执行它的动画,但是一旦它完全离开屏幕并且只有我的主视图可见,屏幕会闪烁,再次快速显示信息视图。我该如何解决这个问题?

【问题讨论】:

    标签: iphone objective-c xcode


    【解决方案1】:

    在我看来,您的 viewController 甚至不应该知道它是模态查看的。

    尝试将发送dismissModalViewController 消息的代码放在主控制器中,并提醒主控制器用户使用委托单击了关闭按钮。

    在你的“父”视图控制器中是这样的

    -(IBAction)showInfo:(id)sender {
        InfoView *info = [[InfoView alloc] initWithNibName:nil bundle:[NSBundle mainBundle]];
        info.modalTransitionStyle = UIModalTransitionStylePartialCurl;
        info.delegate = self;
        [self presentModalViewController:info animated:YES];
        [info release];
    }
    
    -(IBAction)closedButtonClicked {
        [self dismissModalViewControllerAnimated: YES];
    }
    

    在你的“模态”视图控制器中

    -(IBAction) exitInfo:(id)sender {
     [delegate closedButtonClicked];
    }
    

    当然你需要一个像

    这样的协议
    @protocol MyCustomDelegate 
        -(IBAction)closedButtonClicked;
    @end 
    

    在你的“模态”界面中类似这样的东西

    -id<MyCustomDelegate> delegate;
    

    【讨论】:

      猜你喜欢
      • 2010-12-19
      • 1970-01-01
      • 1970-01-01
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多