我更改了 iPhone 应用程序的第一个屏幕,但 uibutton 单击事件不起作用

发布于 2024-12-21 03:35:20 字数 1858 浏览 5 评论 0原文

我改变了我的iPhone应用程序的第一个屏幕,因为我想要一个屏幕,我会在进入主要工作和屏幕之前单击一个按钮。我为此更改了我的应用程序委托代码;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    LoadingViewController *m_view = [[[LoadingViewController alloc]initWithNibName:@"LoadingViewController" bundle:nil] autorelease];

    m_view.window = window;

    [self.window addSubview:m_view.view];
    [self.window makeKeyAndVisible];

    // Override point for customization after app launch    
    //[window addSubview:viewController.view];
    //[window makeKeyAndVisible];
}

我创建了一个视图控制器类;

.h 文件;

#import <UIKit/UIKit.h>

@interface LoadingViewController : UIViewController {
    UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
- (IBAction)startButtonClick:(id)sender;
- (IBAction)favoriButtonClick:(id)sender;

@end

和 .m 文件;

- (IBAction)startButtonClick:(id)sender {
    ScrollViewWithPagingViewController *yellowController = [[ScrollViewWithPagingViewController alloc]initWithNibName:@"ScrollViewWithPagingViewController" bundle:nil];
    [self presentModalViewController:yellowController animated:YES];

    [yellowController release];
}

但是当我单击按钮时,没有出现此单击操作。我之前遇到这样的错误;

此处错误

请帮助我,我不明白出了什么问题?

-----**************************************************** *---- 我解决了!

更改此代码;

LoadingViewController *m_view = [[[LoadingViewController alloc]initWithNibName:@"LoadingViewController" bundle:nil] autorelease];

我删除自动释放;

LoadingViewController *m_view = [[LoadingViewController alloc]initWithNibName:@"LoadingViewController" bundle:nil];

i changed my iphone application first screen because i want to come a screen and i will click a button before going main works and screens. i change my appdelegate code for this;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    LoadingViewController *m_view = [[[LoadingViewController alloc]initWithNibName:@"LoadingViewController" bundle:nil] autorelease];

    m_view.window = window;

    [self.window addSubview:m_view.view];
    [self.window makeKeyAndVisible];

    // Override point for customization after app launch    
    //[window addSubview:viewController.view];
    //[window makeKeyAndVisible];
}

and i create a viewcontroller class;

h file;

#import <UIKit/UIKit.h>

@interface LoadingViewController : UIViewController {
    UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
- (IBAction)startButtonClick:(id)sender;
- (IBAction)favoriButtonClick:(id)sender;

@end

and .m file;

- (IBAction)startButtonClick:(id)sender {
    ScrollViewWithPagingViewController *yellowController = [[ScrollViewWithPagingViewController alloc]initWithNibName:@"ScrollViewWithPagingViewController" bundle:nil];
    [self presentModalViewController:yellowController animated:YES];

    [yellowController release];
}

but when i click the button, didnt come this click action. i get an error before like this;

error here

please help me, i dont understand what is wrong?

-----**********************************************----
i resolved it !

change this code;

LoadingViewController *m_view = [[[LoadingViewController alloc]initWithNibName:@"LoadingViewController" bundle:nil] autorelease];

i delete autorelease;

LoadingViewController *m_view = [[LoadingViewController alloc]initWithNibName:@"LoadingViewController" bundle:nil];

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

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

发布评论

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

评论(1

獨角戲 2024-12-28 03:35:21

看来您的问题可能与您管理窗口的方式有关。您应该只需要使一个键可见,并且不必将窗口包含在视图控制器中(除非您在控制器中执行其他一些特殊操作)。我会保留默认的窗口行为,并将控制器的视图添加为子视图。

Looks like your issue might be related to how you are managing the window. You should only need to make one key and visible and you should not have to include the window in you view controller (unless you are doing some other special thing in the controller). I'd leave te default window behavior and just add your controller's view as a sub view.

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