2013-07-22 2 views
0

TextViewDidEndEditing에 &의 텍스트 뷰가 있습니다. 두 개의 버튼이있는 경고를 표시합니까? 예 아니오iOS SDK의 알림보기 및 작업 시트로 인해 앱이 멈춤

나는 이미지 버튼을 클릭했을 때 텍스트 뷰로 i resignFirstResponder을 입력 했으므로 경고 메시지가 표시됩니다. &에도 작업 시트가 표시됩니다.

하지만 액션 시트 버튼을 클릭 할 수 없습니다. & 앱이 멈췄습니다.

-(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]; 
} 
+0

처음에만 alertview을 시도하는 데 도움이 쇼와 후에 당신의 활동 시트를 엽니 다. –

+0

alertview가 clickable = false에서 다른보기를 표시하는 경우. –

+0

먼저 경고를 사용하고 ActionSheet를 사용하려고 시도하십시오. – Jitendra

답변

0

ResignFirstResponder이 textViewDidiEndEditing 트리거 : 아무것도 다음과 같이

내 코드는 .... 일이 없다. 그래서 기본적으로 당신은 UIAlertVIew와 ActionSheet를 동시에 보여주고 있습니다, 나는 그것이 문제라고 생각합니다.

당신의 UI의 흐름을 정의하고 내가이 구현을위한 코드를 작성이 2

+0

답장을 보내 주셔서 감사합니다 ...하지만 어떻게해야합니까? – user2526811

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 


+0

u는 요구 사항에 따라 위의 코드를 개선 할 수 있습니다. –