0
有没有办法在多个功能之间进行定义?我可以将它定义为一个,但在{}之外不能使用。我需要能够获取来自代码创建的UITextField的文本。我使用的代码如下:保持功能之间的定义
- (void)AlertShow32 {
UIAlertView * alert = [[ [ UIAlertView alloc ] initWithTitle:@"The Most Annoying Button!" message:@"What's your name?"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil ]autorelease];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:myTextField];;
// [myTextField release];
[alert show ];
}
这是定义myTextField将作为UIAlertView中内的文本框的功能。
但我希望能够将myTextField文本保存为我可以在以后的函数中访问的数据,例如我在下面的代码中需要它的位置。
- (void)AlertShow33 {
UIAlertView * alert = [[[[ UIAlertView alloc ] initWithTitle:@"The Most Annoying Button!" message:@"Nice to meet you %i, you have a wierd name!", myTextField.text ]
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil ]autorelease];
alert.transform = CGAffineTransformTranslate(alert.transform, 0.0, 0.0);
[alert show ];
}
柜面有帮助,我打电话给另一个函数的不同功能有:
if (Alerttime == 31) {
[self performSelector:@selector(AlertShow31) withObject:self afterDelay:0.01];
}
if (Alerttime == 32) {
[self performSelector:@selector(AlertShow32) withObject:self afterDelay:0.01];
}
那只是调用这两个功能的一部分,但我定义Alerttime有:
#define int *Alerttime;
Alerttime = 0;
有没有人有任何想法如何我可以从myTextField af功能?
哦,我不认为这会保留函数之间的代码定义对象的文本,我认为每个函数从它的默认开始。 – cowbear16 2011-04-01 10:46:01
我忘了使用自己的线,谢谢。 – cowbear16 2011-04-01 21:12:58