Iphone 将nib文件更改为OPGL ES视图,按钮不';行不通
Hy 更改nib没有问题,但是当我在带有OPGL ES视图的nib文件中时,集成在此视图中的按钮将无法工作。当我按下一个按钮时,应用程序崩溃 这是我如何将视图更改为第二个Nib的代码:Iphone 将nib文件更改为OPGL ES视图,按钮不';行不通,iphone,cocoa-touch,opengl-es,rendering,Iphone,Cocoa Touch,Opengl Es,Rendering,Hy 更改nib没有问题,但是当我在带有OPGL ES视图的nib文件中时,集成在此视图中的按钮将无法工作。当我按下一个按钮时,应用程序崩溃 这是我如何将视图更改为第二个Nib的代码: - (IBAction)drawEAGLView:(id)sender { NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"settingsViewController" owner:self options:nil]; EAGLView*
- (IBAction)drawEAGLView:(id)sender {
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"settingsViewController" owner:self options:nil];
EAGLView* glView = [ nibViews objectAtIndex: 1];
self.view = glView;
[glView startAnimation];}
动画正在运行
这是声明按钮的ViewController的代码:
设置VIEWCONTROLLER.h:
#import <UIKit/UIKit.h>
@interface SettingsViewController : NSObject {
IBOutlet UIButton *wowButton;
}
@property(nonatomic,retain) IBOutlet UIButton *wowButton;
- (IBAction)wowButtonPressed:(id)sender;
int testvarAnimation;
int animNext;
@end
#import <UIKit/UIKit.h>
@class EAGLView;
@interface SettingsViewController : UIViewController {
IBOutlet UIButton *wowButton;
EAGLView *glview;
}
@property(nonatomic,retain) IBOutlet UIButton *wowButton;
@property (nonatomic, retain) IBOutlet EAGLView *glView;
- (IBAction)wowButtonPressed:(id)sender;
int testvarAnimation;
int animNext;
@end
在此,我将向您展示如何连接功能和插座:
如果你需要更多的信息,请告诉我
谢谢为什么我解决了我的问题,我重写了我的视图方法:
- (IBAction)drawEAGLView:(id)sender {
SettingsViewController *sViewController = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];
[[self.view superview] addSubview:sViewController.view];
}
我还更正了我的设置ViewController.h:
#import <UIKit/UIKit.h>
@interface SettingsViewController : NSObject {
IBOutlet UIButton *wowButton;
}
@property(nonatomic,retain) IBOutlet UIButton *wowButton;
- (IBAction)wowButtonPressed:(id)sender;
int testvarAnimation;
int animNext;
@end
#import <UIKit/UIKit.h>
@class EAGLView;
@interface SettingsViewController : UIViewController {
IBOutlet UIButton *wowButton;
EAGLView *glview;
}
@property(nonatomic,retain) IBOutlet UIButton *wowButton;
@property (nonatomic, retain) IBOutlet EAGLView *glView;
- (IBAction)wowButtonPressed:(id)sender;
int testvarAnimation;
int animNext;
@end
我还更改了我的Nib文件。我删除了ViewController,并将文件所有者的类型设置为名为“SettingsViewController”的ViewController。我将文件的所有者Outlet视图与EAGLView连接起来,并将按钮与setingsviewcontrollers wowButtonPressed方法连接起来
我希望我也能帮助别人
谢谢以下是解决此问题的正确方法: 首先,您必须创建视图的parnet对象,以便首先显示。 您需要在第二个视图的头文件中执行此操作
//
// SettingsViewController.h
// NeheTutorial2
//
// Created by Global Sound on 05.04.11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@class EAGLView;
@class mobilesynthViewController;
@interface SettingsViewController : UIViewController {
IBOutlet UIButton *wowButton;
IBOutlet UIButton *optiButton;
EAGLView *glView;
//mobilesynthViewController *mViewController;
mobilesynthViewController *parent;
}
@property(nonatomic,retain) IBOutlet UIButton *wowButton;
@property(nonatomic,retain) IBOutlet UIButton *optiButton;
@property (nonatomic, retain) IBOutlet EAGLView *glView;
//@property(nonatomic,retain) IBOutlet mobilesynthViewController *mViewController;
@property (nonatomic, retain) mobilesynthViewController *parent;
- (IBAction)wowButtonPressed:(id)sender;
- (IBAction)optiButtonPressed:(id)sender;
int testvarAnimation;
int animNext;
int musicOn;
int isAnimating;
float zaehler;
@end
在我的例子中,我正在调用程序主视图中的另一个函数。当按下第二个视图中的按钮时,通过父对象调用第一个视图中的函数
[parent startThread];
在另一个视图中,startThread方法再次被取消
我希望我能帮助你。你需要提供更多的信息。我只能建议您研究XCode创建的OpenGL ES示例项目,并尝试看看它与您的项目有什么不同。很抱歉,我没有提供足够的信息,但我已经改变了解决此问题的方法,但我不知道如何编辑我的问题,或者我应该发布一个新的吗?好的,我设法编辑了这个问题=)为什么又是我?我找到了一个更好的方法来解决这个问题,因为这个解决方案会使设备上的应用程序崩溃。我会在2011年5月7日发布更好的。我很抱歉,但我真的很紧张,很快我就要在学校进行期末考试了!
[parent startThread];