gpt4 book ai didi

iphone - iOs 简单的你好,名称不起作用

转载 作者:行者123 更新时间:2023-11-29 04:59:51 26 4
gpt4 key购买 nike

我最近开始学习Obj-C和Iphone开发,基本上是通过Lynda.com iOs SDK精华类(class)。但它是为 Xcode 3.x 编写的,而我安装了 4.0.x,所以情况有所不同。基本上,我从那里举了例子,它对我来说不起作用,而且我无法弄清楚它是一个菜鸟。

//basicViewController.h
#import <UIKit/UIKit.h>

@interface basicViewController : UIViewController {
IBOutlet UITextField *txtName;
IBOutlet UILabel *lblMessage;
}
@property (nonatomic, retain) IBOutlet UITextField *txtName;
@property (nonatomic, retain) IBOutlet UILabel *lblMessage;

- (IBAction) doSomething;
@end

还有我的 basicViewController.m

#import "basicViewController.h"

@implementation basicViewController
@synthesize txtName;
@synthesize lblMessage;

- (IBAction) doSomething
{
NSString *msg = [[NSString alloc] initWithFormat:@"Hello, %@",txtName.text];
[lblMessage setText:msg];
[msg release];
}

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[super dealloc];
}
@end

我没有更改 basicAppDelegate.h 和 .m 的创建方式。我想无论如何我都会发布它们。

//
// basicAppDelegate.h

#import <UIKit/UIKit.h>

@class basicViewController;

@interface basicAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
basicViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet basicViewController *viewController;

@end


//
// basicAppDelegate.m

#import "basicAppDelegate.h"
#import "basicViewController.h"

@implementation basicAppDelegate

@synthesize window;
@synthesize viewController;


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

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


- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}


@end

这是我的 main.m:

//
// main.m


#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

此外,在 Interface Builder 窗口中,我已通过 File's Owner: label 链接到 lblMessage,TextField 链接到 txtName,doSomething 链接到 Button。

现在的问题是:实际上,只有当我使用弹出键盘而不是物理键盘时,这件事才有效。并且仅当我输入少于 3-4-5 个符号时(有时会有所不同)。如果我使用我的键盘,而不是弹出键盘 - 它会给我线程 1 收到的信号 EXC_BAD_ACCESS。如果我输入太多符号也是如此。

我在“所有输出”中没有看到太多 - 只是一些常见的东西,唯一可疑的行是:

warning:unable to compile regular expression "dyld"
Current language: auto; currently objective-c
(gdb)

所以,伙计们,我们非常感谢任何善意的帮助。

最佳答案

首先,自 Xcode 3 以来,除了界面之外,没有任何变化。

尝试设置断点并查看应用程序崩溃的位置...

尝试删除 IBOutlet 并创建新的...

尝试创建一个新的应用程序...

如果以上方法均无效,请将您的 Mac 扔出窗外,然后将其带回 Apple。 (或者再次安装 Xcode --> 便宜得多..)

关于iphone - iOs 简单的你好,名称不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7222335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com