2012-07-25 3 views
0

는 내가 텍스트 필드와의 alertview를 생성하고 텍스트 필드에 삽입 된 세부 내가 button.here 여기 qtystr 내 코드액세스 텍스트 필드의 데이터는 전 세계적으로

-(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); } 

, txtfield 내가이 선택하면 액세스 할 수 있습니다 당신이 그것을 놓치고있는 곳을 알지 못한다. ...

답변

1

qtystr이 속성 일 경우 참조 할 때 self.qtystr을 사용하십시오.

(그렇지 않으면 qtystr=str;에 중단 점을 사용하여 할당 중에 값이 무엇인지 확인하십시오.)

관련 문제