0

我有一个 textView & on TextViewDidEndEditing,我显示一个带有两个按钮保存的警报?是的 没有。

我也有图像按钮,当它被单击时我resignFirstResponder为 textview,所以警报将被显示并且还显示操作表。

但是操作表按钮不可点击并且应用程序挂起。什么都没有发生......

我的代码如下:

-(void)textViewDidEndEditing:(UITextView *)textView
{
UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"" message:@"Do you want to save this note?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
    [alt setTag:1];
    [alt show];
}

-(IBAction)image_button:(id)sender
{
[MYTextView resignFirstResponder];
UIActionSheet *ac=[[UIActionSheet alloc]initWithTitle:@"Select the Option" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Photo Library",@"Camera Capture", nil];
    ac.tag=4;
    ac.delegate = self;
    ac.backgroundColor=[UIColor blackColor];
    [ac showInView:self.view];
}
4

2 回答 2

0

听说我写了实现这个啤酒花的代码,这有帮助


  #import "ViewController.h"

 @interface ViewController ()<UITextViewDelegate,UIAlertViewDelegate,UIActionSheetDelegate>

 @end

 @implementation ViewController
 @synthesize aTextView;
 @synthesize aButton;

- (void)viewDidLoad
{
    [super viewDidLoad];
     self.aTextView.delegate = self;

// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
 {
     [super didReceiveMemoryWarning];
     // Dispose of any resources that can be recreated.
 }

 - (void)dealloc {
     [self.aTextView release];
     [self.aButton release];
     [super dealloc];
   }
 -(void)textViewDidEndEditing:(UITextView *)textView
 {



  }
  -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
 {
      if(buttonIndex == alertView.cancelButtonIndex)
      {
           NSLog(@"cancel");
      }
       else
      {
          NSLog(@"save hear");


          UIActionSheet *aActionSheet = [[UIActionSheet alloc]initWithTitle:@"option" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:nil otherButtonTitles:@"photo lib",@"camara lib", nil];
          [aActionSheet showInView:self.view];
          [aActionSheet release];

      }

   }




  - (IBAction)whenButtonTapped:(id)sender {
      [self.aTextView resignFirstResponder];

      UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"save" message:@"" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES",nil];
      [alertView show];
      [alertView release];



   }

  -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
   {
     if(buttonIndex == actionSheet.cancelButtonIndex)
       {
           NSLog(@"cancel");
       }
     else if (buttonIndex == 0)
       {
           NSLog(@"save to photo lib");
        }
      else
       {
           NSLog(@"camara lib");
       }
   }

   @end


于 2013-07-22T13:33:30.290 回答
0

ResignFirstResponder 触发 textViewDidiEndEditing。所以基本上你同时显示 UIAlertVIew 和 ActionSheet,我想这就是问题所在。

请定义您的 UI 流程并尝试将这 2 个分开。

于 2013-07-22T12:53:32.827 回答