-4

ダウンロードしたコントロールに問題があります。ボタンが押されたときに背景を変更したいのですが、ボタンが押されたときに、現在のイベントが終了するまでアプリはイベントをリッスンしないようです。ここに私のコードがあります

-(void) menuItem:(RRCircularItem *)item didChangeActive:(BOOL)active {

    [menu progress];
    [menu setBackgroundColor1:[UIColor colorWithPatternImage:[UIImage imageNamed:@"menuabiertoloadingretina.png"]]];
    [menu hideWithAnimationBlock:^{
        self.view.backgroundColor = [UIColor whiteColor];
    }];
    [menu release], menu = nil;
     self.viewCarga.hidden = NO;
    [menu setBackgroundColor1:[UIColor colorWithPatternImage:[UIImage imageNamed:@"menuabiertoloadingretina.png"]]];
    NSLog(@"Item %@ did change state to %d", item.text, active);
    if ([item.text isEqualToString:@"EDITORIALES"]){

        ViewController *viewControler = [[ViewController alloc] initWithNibName:@"EditorialesViewController" bundle:nil];
        [self presentViewController:viewControler animated:YES completion:nil];
        [menu setBackgroundColor1:[UIColor colorWithPatternImage:[UIImage imageNamed:@"menuabiertoloadingretina.png"]]];

    }else if ([item.text isEqualToString:@"GOLES"]){

        GolViewController *viewControler = [[GolViewController alloc] initWithNibName:@"GolViewController" bundle:nil];

        [self presentViewController:viewControler animated:YES completion:nil];
    }else if ([item.text isEqualToString:@"TABLA"]){

        WebViewController *viewControler = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];

        [self presentViewController:viewControler animated:YES completion:nil];
    }else if ([item.text isEqualToString:@"AUNLI"]){

        AUNLIViewController *viewControler = [[AUNLIViewController alloc] initWithNibName:@"AUNLIViewController" bundle:nil];

        [self presentViewController:viewControler animated:YES completion:nil];
    }else if ([item.text isEqualToString:@"HORARIOS"]){

        HorariosViewController *viewControler = [[HorariosViewController alloc] initWithNibName:@"HorariosViewController" bundle:nil];

        [self presentViewController:viewControler animated:YES completion:nil];
    }

    if (active && ![menu isLabelActive]) {
        [menu setLabelActive:YES];
        [menu setSliderValue:1];
    } else if (!active && [menu isLabelActive]) {
        BOOL hasActive = NO;
        for (int i = 0; i < 6; i++) hasActive |= [menu isItemActive:i];
        if (!hasActive) {
            [menu setLabelActive:NO];
            [menu setSliderValue:0 animated:NO];
        }
    }
}

すべての前にこのイベントを使用したいのです[menu progress];が、機能していません。

4

1 に答える 1

0

if i understand Well, you press some button and you stay lock.Its because you are doing everything in main thread. Thats why you need to use threads, this way you will do multi sync/async processes preventing locks in your app. You can use NSThread, dispatch or NSOperationQueue...I like to use GCD(Grand Central Dispatch)

Sample:

    dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
    //Background Thread
    dispatch_async(dispatch_get_main_queue(), ^(void){
        //User Interface Updates
    });
});
于 2013-07-01T19:35:28.533 に答える