我更改了 iPhone 应用程序的第一个屏幕,但 uibutton 单击事件不起作用
我改变了我的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;
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您的问题可能与您管理窗口的方式有关。您应该只需要使一个键可见,并且不必将窗口包含在视图控制器中(除非您在控制器中执行其他一些特殊操作)。我会保留默认的窗口行为,并将控制器的视图添加为子视图。
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.