2012-06-06 2 views
0

사용자가 textfiled에 잘못된 값을 입력하면 알림이 표시되고 텍스트 필드 emty와 버튼 제목도 비어있게하고 싶습니다. 내 코드 텍스트 필드는 비어 있지만 버튼이 있습니다. 직접UIButton의 제목이 비어 있거나 아이폰에 공백으로 설정되어 있지 않습니다.

처럼 할당하면 어떻게됩니까 내 코드

 if (monthText>totalnumber) { 
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Value Must Be Less than total number of dogs " delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [alert show]; 
    [alert release]; 

    NSString *titleMonth [email protected]"0"; 
    [cereniaButton setTitle:@"" forState:UIControlStateNormal]; 






    [email protected]""; 


    } 


int year=12; 
int monthButtonTitle=monthText*year; 
NSString *titleMonth =[NSString stringWithFormat:@"%d",monthButtonTitle]; 
[cereniaButton setTitle:titleMonth forState:UIControlStateNormal]; 
+0

당신이 "지정을 시도 할 수 있습니다"는 NSString과 * titleMonth = @ ""; – CarlJ

+0

도 표시되지 않습니다 – james

+0

NSLog (@ "% @", cereniaButton)를 게시 할 수 있습니까? – CarlJ

답변

0

당신이 제목을 재설정하는 것이 아니라 제목이 ripopolate 것입니다 후 제목을 설정 한 후이 라인.

날 u는 파일의 소유자와 버튼을 연결하는 누락 될 수

0

빈 값 아래

입니다 못하고있다 [BTN의 setTitle이라는에게 : @ ""forState : UIControlStateNormal]

+0

비어 있지 않음을 표시하고 있습니다 이전 값 – james

+0

내 편집 코드 – james

+0

을 볼 수 있습니다. 그러면 이전 값이 일부 문자열에 저장되고 위의 행이 실행될 수 있습니다 , 그 코드를 배치 할 수있는 코드가있을 수 있습니다. 단추의 제목으로 문자열 다시. – Dhruv

0

쓰기 버튼

[self.view setNeedsDisplay]; 
0

을 알려

if (monthText>totalnumber) { 
    //...yourcode... 

    return; 
} 

을 시도,이 시도 :

  1. .H 파일, 버튼에서 버튼에 함께 IBOutlet 선언 그것은 xib에 의해 만들어집니다.
  2. @b에서 bsn을 합성합니다.
  3. xib의 파일 소유자에 버튼 (btn)을 연결하십시오. 이 대리자를 사용

- (무효) textFieldDidEndEditing : (UITextField에 *)에 textField

int txtValue = [textField.text intValue]; 
if(txtValue < 10) 


    btn.titleLabel.text = [NSString stringWithFormat:@"%d",txtValue]; 
     else 
     { 
      btn.titleLabel.text = [NSString stringWithFormat:@""]; 
     } 
    } 
    - (BOOL)textFieldShouldReturn: (UITextField *)textField 
    { 
     [textField resignFirstResponder]; 
     return YES; 
    } 
관련 문제