2011-04-20 11 views
11

मैंने यूआईपीकर में यूआईपीकर को दिखाने के लिए इस कोड का उपयोग किया था, लेकिन जब मैं बंद बटन पर क्लिक करता हूं तो मैं एक्शन शीट को देखने से हटाना चाहता हूं। तो एक्शनशीट फॉर्म व्यू को हटाने के लिए कोड क्या होना चाहिए।एक्शन शीट को कैसे खारिज करना है

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{ 
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; 

[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent]; 

CGRect pickerFrame = CGRectMake(0, 40, 0, 0); 

pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame]; 
pickerView.showsSelectionIndicator = YES; 
pickerView.dataSource = self; 
pickerView.delegate = self; 

[actionSheet addSubview:pickerView]; 
[pickerView release]; 

UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]]; 
closeButton.momentary = YES; 
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f); 
closeButton.segmentedControlStyle = UISegmentedControlStyleBar; 
closeButton.tintColor = [UIColor blackColor]; 
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged]; 
[actionSheet addSubview:closeButton]; 
[closeButton release]; 

[actionSheet showInView:self.view];//[UIApplication mainWindow]]; 

[actionSheet setBounds:CGRectMake(0, 0, 320, 485)]; 
return false; 
} 
+0

मैं का इस्तेमाल किया है [actionsheet removeFromSuperview] ; लेकिन यह काम नहीं कर रहा है। –

+0

देखें http://stackoverflow.com/questions/1551587/how-to-dismiss-uiactionsheet- स्वचालित रूप से –

उत्तर

11

आप सभी को खारिज कर रहा है ActionSheet, जो आप dismissWithClickedButtonIndex:animated:

+0

हे, पहले से ही इसे स्वयं समझ लिया: पी – ttarik

+0

आपकी अच्छी मदद के लिए धन्यवाद –

+0

स्विफ्ट के बारे में क्या? – dylan

4

एक्शन शीट स्कोप समस्या।

[actionSheet dismissWithClickedButtonIndex:0 animated:YES];

+0

आपने इसका उपयोग कहां किया? मैंने एक अस्वीकरण एक्शनशीट विधि बनाने की कोशिश की, और इसमें [actionSheet dismisswithith ...] डाल दिया, लेकिन ऐसा लगता है कि यह काम नहीं कर रहा है। –

7

जोड़ा जा रहा है इस विधि मेरे लिए काम किया के साथ कर सकता क्या करने की जरूरत के लिए इस्तेमाल किया:

-(void) dismissActionSheet:(id)sender { 
     UIActionSheet *actionSheet = (UIActionSheet *)[(UIView *)sender superview]; 
     [actionSheet dismissWithClickedButtonIndex:0 animated:YES]; 
    } 
+0

मेरा प्रेषक एक UIBarButtonItem है जो एक म्यूटेबल सरणी में जोड़ा जाता है जिसे UIToolBar में जोड़ा जाता है जिसे वर्कशीट में सबव्यूव के रूप में जोड़ा जाता है। मैं बर्खास्तगी विधि में कार्यपत्रक का उपयोग कैसे करूं? – marciokoko

संबंधित मुद्दे