2011-02-06 3 views
1

저는 cocos2d를 사용하고 있으며, CCMenuItemFont의 IF 텍스트를 두드려면 UIAlertView가 팝업되도록하고 싶습니다. alertView를 팝업으로 표시 할 수 있지만 텍스트를 두드린 후 다시 표시하려고합니다. 여기에 내 코드 INIT입니다CCMenuItemFont (텍스트)가 탭 된 경우 UIAlertView

rate = [CCMenuItemFont itemFromString:@"Rate App" target:self selector:@selector(rateIsTapped:clickedButtonAtIndex:)]; 
    rate.position = ccp(240, 160); 
    [self addChild:rate]; 



-(void)rateTapped:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {  
rateView = [[UIAlertView alloc] initWithTitle:@"Like This App?" message:@"Rate it on the App Store!" delegate:self cancelButtonTitle:@"No thanks" otherButtonTitles:@"Sure, I'll rate it!", nil]; 
[rateView show]; 
[rateView autorelease]; 
[defaults setBool:YES forKey:@"rate"]; 

if (buttonIndex == 0) { 
    //[alertView collapse]; 
} 
if (buttonIndex == 1) { 
    NSURL *url = [NSURL URLWithString:@"LINK TO RATE IN APP STORE"]; 
    [[UIApplication sharedApplication] openURL:url]; 
} 

}

답변

0

코드는 .. 잘못 그것은 ... 쇼 경고와 함께 도청 안 그리고 당신이 CCMenu에 menuitemFont을 추가해야합니다 ..

rate = [CCMenuItemFont itemFromString:@"Rate App" target:self selector:@selector(rateApp)]; 

CCMenu* menu = [CCMenu menuWithItems:rate, nil]; 
    menu.position = CGPointMake(-(size.width/2), size.height/2); 
    menu.tag = 100; 
    [self addChild:menu]; 


-(void)rateApp 
{ 
rateView = [[UIAlertView alloc] initWithTitle:@"Like This App?" message:@"Rate it on the App Store!" delegate:self cancelButtonTitle:@"No thanks" otherButtonTitles:@"Sure, I'll rate it!", nil]; 
[rateView show]; 
[rateView release]; 
[defaults setBool:Yes forKey:@"rate"]; 
} 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 
{ 
if (buttonIndex == 0) { 
//[alertView collapse]; 
} 

if (buttonIndex == 1) { 
    NSURL *url = [NSURL URLWithString:@"LINK TO RATE IN APP STORE"]; 
    [[UIApplication sharedApplication] openURL:url]; 
} 
} 
+0

시뮬레이터에서 평가판 앱을 클릭해도 아무런 변화가 없습니다. 하지만 아무런 충돌이 없습니다 – Joethemonkey101

+0

그리고 네, 그것을 2 방법으로 변경하고 선택기는 첫 번째 방법 (속도) – Joethemonkey101

+0

NSLog 속도 애플 리케이션 기능 .. 그것은 기능을 실행 했습니까 ?? – xuanweng