我创建了一个带有文本字段的警报视图,当我选择一个按钮时,必须访问插入到文本字段中的详细信息。这是我的代码
-(IBAction)addcart:(id)sender{
UIAlertView *customAlertView = [[UIAlertView alloc] initWithTitle:@"Enter Your quantity" message:@"" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:@"Cancel", nil];
txtfield = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 40.0, 260.0, 20.0)];
[txtfield setBackgroundColor:[UIColor whiteColor]];
[txtfield setKeyboardType:UIKeyboardTypeNumberPad];
[customAlertView addSubview:txtfield];
[customAlertView show];
[customAlertView release]; }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
if (buttonIndex == 0)
{
NSString* str=txtfield.text;
qtystr=str;
}
-(IBAction)showcontent:(id)sender{
NSLog(@"%@",qtystr); }
在这里 qtystr,txtfield 我创建了属性并合成了它..但我不知道我在哪里错过它...