2011-04-26 4 views
1

다른 변수에서 alertView에 여러 메시지를 표시하려면 어떻게해야합니까?UIAlertView 다중 메시지 표시

+0

무엇이 여러 개입니까? 질문을 설명해주세요 .... –

+0

여러 메시지를 말하고있는 것이 무엇입니까 ??? –

+0

은 다른 값과 다른 타이틀을 좋아합니다. 재생 시간과 같이 : 30, 점수 : 90 %. 그리고 다른 라인에 표시하십시오. 지금은 명확합니까? –

답변

3

예를 들어, 귀하의 여러 변수에서 원하는 NSString, 빌드 :

NSString *myTitle = @"xyz"; 
UIAlertView *alert = [[UIAlertView alloc] 
         initWithTitle: myTitle 
         message: myMessage 
         delegate: nil 
         cancelButtonTitle: @"OK" 
         otherButtonTitles: nil]; 
[alert show]; 
[alert release]; 
+0

제목과 값을 여러 줄로 표시하고 싶습니다. 예를 들어 ... 총 재생 시간 : 30, 총점 : 90 ... 계산 된 값은 이제 해당 제목과 함께 표시해야합니다. 지금 아이디어가 있습니다. ? –

+0

"여러 줄"을 갖기 위해 줄 바꿈 문자 ('\ n')를 메세지 문자열에 추가 할 수 있습니다 : http://en.wikipedia.org/wiki/Newline –

+0

감사합니다. 나는 동적 인 AlertViewController를 만들 수있다 ... 어떤 생각이든 이것을하는 방법? –

1
NSString *[email protected]"total time played:30\n"; 
    NSString *[email protected]"total score :90\n"; 
    NSString *[email protected]"19/2/20010 12:00:77\n"; 
    NSString *string=[NSString stringWithFormat:@"%@%@%@",string1,string2,string3]; 
    UIAlertView *progressAlert = [[UIAlertView alloc] initWithTitle:@"Hello" message:string delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
    [progressAlert show]; 
    [progressAlert release]; 
+0

게임을 끝내고 show.time, score, correctAns, wrongAns 등을 입력하지 않아도됩니다. 다중 행과 해당 값을 표시해야합니다. 내 접근 방식으로 어떻게 할 수 있습니까? –

+1

내 편집 된 답변보기 방법 당신은 별도의 줄에 텍스트를 표시 할 수 있습니다 – Gypsa

+1

나는 그것이 당신을 위해 작동 희망! – Gypsa

0

당신은 살을하실 수 있습니다 :

NSString *foo; 
NSString *bar; 
NSString *baz; 
// ... set values for foo, bar and baz ... 
NSString *myMessage = [NSString stringWithFormat:@"%@ %@ %@", foo, bar, baz]; 

그런 다음 복합 메세지 myMessage를 사용하도록 경고보기 설정을 귀하의 질문에 조금 더,하지만 귀하의 질문에 대한 이해에서 일하고, 당신은 단지 사용할 수 있어야합니다

- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... 

UIAlertView 생성자. 그런 다음 변수를 단일 NSString 객체로 연결하고 (NSString*)message으로 전달하십시오. The

+ (id)stringWithFormat:(NSString *)format, ... 

공장 방법은이 작업을 간단하게 만듭니다. reading your options with NSString in the Apple documentation을 권하고 싶습니다.

1
NSString *[email protected]"Message 1."; 
NSString *str2= @"Message 2."; 
NSString *str3 = @"Message 3"; 


NSString *msg=[NSString stringWithFormat:@"%@\n%@\n%@",str1,str2,str3]; 


FreeCoinsCustomAlert* alert = [[FreeCoinsCustomAlert alloc] initWithTitle:msg 
                    message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 

[alert show]; 
[alert release];