0

在我的应用程序中,我有 7 个按钮,按下向下箭头后,我在该视图中显示 3 个按钮,它显示其他 3 个按钮

1.Facebook 分享 2.twitter 分享 3.告诉朋友 4.报告 5.入门指南 6.访问我的网站 7.反馈

     LIKE THIS MY VIEW
    ====================
          ^        ---->up arrow

      facebook share

      Twitter share

      Tell a friend

           V      ---->down arrow

我正在使用 mailcomposerview 作为“告诉朋友”按钮和“报告”按钮

当我按下“告诉朋友”或“报告”按钮时,它会在关闭后打开 mailcomposerview,我无法移动向上和向下箭头......如果我按下向上和向下箭头,它会打开相同的邮件 composerview ,它也没有打开 facebook 分享和 twitter 分享

请帮我解决这个问题

按下箭头时我的编码

 -(void)arrTapped1:(id)sender
 {
CCMenuItem *item2=(CCMenuItem*)sender;
int k=item2.tag;
    ////CCLOG(@"k tapp=%dhelp=%d",k,helpVal);

    NSLog(@"HelpVal%i",helpVal);
if(k==51)
{
    if(helpVal<3)
    { 
        id action1=[CCMoveBy actionWithDuration:0.3 position:ccp(0,+260)];
        id callfun1=[CCCallFunc actionWithTarget:self selector:@selector(enabled1) ]; 

        [item2 setIsEnabled:YES];
        [(CCSprite*)[self getChildByTag:10] runAction:[CCSequence actions:action1,callfun1,nil]];
        [self performSelector:@selector(downWardsMove)];
            }

}
else //if(k==50)
        {
    if(helpVal>1)
    {  

        id action1=[CCMoveBy actionWithDuration:0.3 position:ccp(0,-260)];
        id callfun1=[CCCallFunc actionWithTarget:self selector:@selector(enabled1) ]; 
        [item2 setIsEnabled:YES];

        [(CCSprite*)[self getChildByTag:10] runAction:[CCSequence actions:action1,callfun1,nil]];
        [self performSelector:@selector(upWardsMove)];
    }   } }

    //code for upwards & downwards move
    //--------------------------------

  -(void)upWardsMove
   {
      [upArrItem setIsEnabled:NO];
  [downArrItem setIsEnabled:NO];
  self.isTouchEnabled=NO;
  helpVal--;
  [(CCMenu*)[self getChildByTag:53] setVisible:YES];
  [downArrItem setIsEnabled:YES];
      if(helpVal==1)
  {
    [(CCMenu*)[self getChildByTag:52] setVisible:NO];
    [upArrItem setIsEnabled:NO];
  } 
   }


-(void)downWardsMove
 {
    [upArrItem setIsEnabled:NO];
[downArrItem setIsEnabled:NO];
self.isTouchEnabled=NO;
    helpVal++;
    [(CCMenu*)[self getChildByTag:52] setVisible:YES];
[upArrItem setIsEnabled:YES];
if(helpVal==3){
    [(CCMenu*)[self getChildByTag:53] setVisible:NO];
    [downArrItem setIsEnabled:NO];
}
}
 -(void)enabled1
  {
self.isTouchEnabled=YES;
[upArrItem setIsEnabled:YES];
[downArrItem setIsEnabled:YES];
if(helpVal==3)
{
    [(CCMenu*)[self getChildByTag:53] setVisible:NO];
    [downArrItem setIsEnabled:NO];
}
if(helpVal==1)
{
    [(CCMenu*)[self getChildByTag:52] setVisible:NO];
    [upArrItem setIsEnabled:NO];
}
   }

 //sending mail code
//------------------

-(void)sendMail
{
  mailComposer = [[UIViewController alloc] init];
  [[[CCDirector sharedDirector] openGLView] addSubview:mailComposer.view];
  MFMailComposeViewController *mailController= [[MFMailComposeViewController alloc] init];                
  mailController.mailComposeDelegate = self;    
  [mailController setSubject:msgSubject];
  [mailController setMessageBody:mailContent isHTML:YES];
  NSArray *toRecipients = [NSArray arrayWithObject:@"Info@ask.com"];
  [mailController setBccRecipients:toRecipients];
  [mailComposer presentModalViewController:mailController animated:NO];
  mailComposer.view.transform = CGAffineTransformMakeRotation( CC_DEGREES_TO_RADIANS(90.0f ) );
  [mailController release];
  [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight]     
  }

 -(void)mailComposeController:(MFMailComposeViewController*)mailController didFinishWithResult: (MFMailComposeResult)result  error:(NSError*)error
 {
    [mailComposer dismissModalViewControllerAnimated:YES];
 }
4

2 回答 2

0

这是我在应用程序中使用的代码的一部分,它在 iOS 4.0 - iOS 6.0 中运行良好。看一看:

-(void)sendMessageToEmail:(NSString *)message withSubject:(NSString *)subject
{
    if([self _isIOS6andHigher]) {

        NSArray *activities = @[message];
        UIActivityViewController *viewController = [[UIActivityViewController alloc] initWithActivityItems:activities applicationActivities:nil];

        AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
        [[app navController] presentViewController:viewController animated:YES completion:nil];
        [viewController release];

    } else {

        MFMailComposeViewController* mailController = [[MFMailComposeViewController alloc] init];
        mailController.mailComposeDelegate = self;
        [mailController setSubject:subject];
        [mailController setMessageBody:message isHTML:NO];

        AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
        [[app navController] presentModalViewController:mailController animated:YES];
        [mailController release];
    }
}

- (void)mailComposeController:(MFMailComposeViewController*)controller
      didFinishWithResult:(MFMailComposeResult)result
                    error:(NSError*)error
{
    [controller dismissModalViewControllerAnimated:YES];

}
于 2012-12-15T08:57:42.310 回答
0

你永远不会发布 mailComposer:

mailComposer = [[UIViewController alloc] init];

这可能会导致它泄漏并作为视图保持活动状态。这可以解释缺少触摸事件的原因,因为邮件编写器可能仍会拦截触摸。

于 2012-12-15T14:40:15.153 回答