0

テキストフィールドを使用してアラートビューを作成しました。ボタンを選択すると、テキストフィールドに挿入された詳細にアクセスする必要があります。コードは次のとおりです。

-(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私はプロパティを作成し、それを合成しました..しかし、私はそれがどこに欠けているのかわかりません...

4

1 に答える 1

1

qtystrがプロパティの場合self.qtystr、それを参照するときに使用します。

(それ以外の場合は、ブレークポイントを使用してqtystr=str;、割り当て中の値を確認します。)

于 2012-07-25T11:08:17.697 に答える