2010-11-20 25 views
0

ben uzun ileti görüntüler için basit bir uyarı kullanıyorum ve ben şu şekilde uyarısı işlemek:iphone UIAlertView odak sorunu

 

bool  hold_alert = true; 
UIAlertView * malert = [[UIAlertView alloc]....create the alert 
[malert show]; 
while(hold_alert) 
{//hold the application focus on the alert, when alert triggers the function with "clickedButtonAtIndex" i set hold_alert to false 
    CFRunLoopRunInMode(kCFRunLoopDefaultMode,0.05,false); 
} 
[malert removeFromSuperView]; 
[my_window becomeFirstResponder]; 
... release alert and stuff , and carry on... 
 

sorun bu kod Başvurumda odağı bırakmayacaktır olmasıdır . Bu kod parçasını ayrılıklar kullanarak hata ayıklayıcısında çalıştırdığımda, kontrol başarıyla uygulamam için geri yüklenir. Bunu nasıl düzeltebilirim?

Teşekkürler, Raxvan.

cevap

1

Onun

Ama belki

-(void)presentAlert 
{ 
UIAlertView * malert = UIAlertView *aview = [[[UIAlertView alloc] initWithTitle:@"Blah" message:@"blah blah" cancelButtonTitle:@"OK" delegate:self otherButtonTitles:nil] autorelease];                                                  
[malert show]; 
} 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex) { foo } 
} 

yönetiminde kalan saygı ile sizin için yapıldığı gibi İstediğin ... burada runloop fonksiyonu ile ne elde etmek istediğinizi biraz belirsiz bellek ve görünümler. Açıkça uyarıya odaklanmaya gerek yoktur.

uyarı, olduğu gibi bir yinelenen zamanlayıcı kovabilirsin yukarı iken yapmak istediğin şey olsaydı.

-(void)presentAlert 
    { 
    UIAlertView * malert = UIAlertView *aview = [[[UIAlertView alloc] initWithTitle:@"Blah" message:@"blah blah" cancelButtonTitle:@"OK" delegate:self otherButtonTitles:nil] autorelease];                                                  
    [malert show]; 
    iTimer = [[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(doStuff:) userInfo:nil repeats:YES] retain]; 

    } 

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
    { 
    [iTimer invalidate]; 
    [iTimer release]; 
    if (buttonIndex) { //foo } 
    } 

    -(void)doStuff:(NSTimer *)aTimer 
    { 
     //bar 
    }