पर टेक्स्टफ़िल्ल्ड जोड़ना मुझे TextField
को UIAlertView
में जोड़ने की आवश्यकता है। मैं समझता हूं कि सेब इस दृष्टिकोण को हतोत्साहित करता है। तो क्या कोई पुस्तकालय है जिसे मैं TextField
को UIAlertView
में समान रूप से फ्रेम जोड़ने के लिए उपयोग कर सकता हूं? इस तरहUIAlertView
उत्तर
कोशिश कुछ:
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Title"
message:@"\n\n"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Save", nil] autorelease];
CGRect rect = {12, 60, 260, 25};
UITextField *dirField = [[[UITextField alloc] initWithFrame:rect] autorelease];
dirField.backgroundColor = [UIColor whiteColor];
[dirField becomeFirstResponder];
[alert addSubview:dirField];
[alert show];
आप कोशिश कर सकते हैं:
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here!" message:@"this gets covered" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[myAlertView addSubview:testTextField];
[myAlertView show];
[myAlertView release];
विस्तार के लिए इस link का पालन करें।
हां, आपका कोड काम करता है। लेकिन एप्पल निजी एपीआई का उपयोग करते हुए इस दृष्टिकोण को हतोत्साहित करता है। तो क्या कोई और तरीका है जिसे मैं हल कर सकता हूं? – shajem
यहां कोई निजी एपीआई नहीं है .. –
@ अनामित ओपी दस्तावेज़ों से उस वाक्य को संदर्भित करता है: इस वर्ग के लिए दृश्य पदानुक्रम निजी है और इसे संशोधित नहीं किया जाना चाहिए। –
इसे देखें ... http://iosdevelopertips.com/undocumented/alert-with-textfields.htmlयह निजी एपीआई है और यदि आप इसे ऐपस्टोर में ऐप के लिए उपयोग करते हैं तो इसे अस्वीकार कर दिया जा सकता है लेकिन यह उद्यम विकास के लिए ठीक है।
आपके उत्तर के लिए धन्यवाद, लेकिन मैं अपने ऐप को ऐपस्टोर पर प्रकाशित करने की उम्मीद कर रहा हूं: एस – shajem
मैं सलाह नहीं दूंगा कि आपको इसे लागू करना चाहिए। –
मैं अलर्ट व्यू और एक्शनशीट्स के लिए ऐप्पल घटकों के बजाय BlockAlertsAndActionSheets का उपयोग कर रहा हूं क्योंकि मैं ब्लॉक-दृष्टिकोण पसंद करता हूं। स्रोत में BlockTextPromptAlertView
भी शामिल है, जो आप चाहते हैं कि हो सकता है। ऐप्पल-शैली को वापस पाने के लिए आप उस नियंत्रण की छवियों को प्रतिस्थापित कर सकते हैं।
Tutorial which gets you started
उदाहरण:
- (IBAction)newFolder:(id)sender {
id selfDelegate = self;
UITextField *textField;
BlockTextPromptAlertView *alert = [BlockTextPromptAlertView promptWithTitle :@"New Folder"
message :@"Please enter the name of the new folder!"
textField :&textField];
[alert setCancelButtonWithTitle:@"Cancel" block:nil];
[alert addButtonWithTitle:@"Okay" block:^{
[selfDelegate createFolder:textField.text];
}];
[alert show];
}
- (void)createFolder:(NSString*)folderName {
// do stuff
}
क्या आप मुझे एक उदाहरण दिखा सकते हैं जो 'BlockTextPromptAlertView' का उपयोग करता है। मैं इस धारणा के तहत हूं कि डेवलपर्स को UIAlertView में कोई टेक्स्टफील्ड इत्यादि जोड़ने की अनुमति नहीं है। – shajem
आप अपनी इंप्रेशन के साथ सही हैं। यही कारण है कि BlockAlertsAndActionSheets ** ** ** UIAlertView का उपयोग कर ** नहीं है, यह किसी भी निजी एपीआई के इस्तेमाल किए बिना पूरी तरह से स्वतंत्र कार्यान्वयन है। मेरे पास अभी मेरे स्रोतों तक पहुंच नहीं है, लेकिन कुछ घंटों में कोड नमूना के साथ मेरा जवाब अपडेट कर सकता है। –
उदाहरण के उपयोग के साथ अद्यतन –
दुर्भाग्य से इस के लिए केवल सरकारी एपीआई iOS 5 और ऊपर, यह एक संपत्ति alertViewStyle
कहा जाता है जो निम्नलिखित मानकों सेट किया जा सकता है:
UIAlertViewStyleDefault
UIAlertViewStyleSecureTextInput
UIAlertViewStylePlainTextInput
UIAlertViewStyleLoginAndPasswordInput
UIAlertViewStylePlainTextInput
जो आप चाहते हैं वह हो।
ऊपर वर्णित दृश्य पदानुक्रम के साथ मेसिंग ऐप्पल द्वारा दृढ़ता से निराश है।
में 'एनिमेट विथ अवधि' की खोज करने का प्रयास करें, मुझे इसे आईओएस 4 और 5 के लिए बनाना होगा। तो क्या आप जानते हैं कोई अन्य लाइब्रेरी जहां मैं उपयोग कर सकता था – shajem
iOS5 के लिए:
UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Title" message:@"Please enter someth" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
av.alertViewStyle = UIAlertViewStylePlainTextInput;
[av textFieldAtIndex:0].delegate = self;
[av show];
इसके अलावा, आप 'UITextFieldDelegate
, UIAlertViewDelegate
प्रोटोकॉल को लागू करने की आवश्यकता होगी।
'Shmidt', UIAlertView में दर्ज किए गए पाठ पर कब्जा करने के कोड से जवाब देने के लिए जोड़ने नीचे चिपकाया जाता है (धन्यवाद 'वेन Hartman' Getting text from UIAlertView)
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
self.userNumber = [alertView textFieldAtIndex:0].text;
if (self.userNumber) {
// user enetered value
NSLog(@"self.userNumber: %@",self.userNumber);
} else {
NSLog(@"null");
}
}
}
iOS 8 UIAlertView
के रूप में के पक्ष में पदावनत कर दिया गया है UIAlertController
, जो UITextField
पद्धति का उपयोग करके रों जोड़ने के लिए समर्थन जोड़ता:
- (void)addTextFieldWithConfigurationHandler:(void (^)(UITextField *textField))configurationHandler;
एक उदाहरण के लिए this answer देखें।
सभी में से पहले ViewController में UIAlertViewDelegate जोड़ें।
#import <UIKit/UIKit.h>
@interface UIViewController : UITableViewController<UIAlertViewDelegate>
@end
की तरह और कोड जहां आप प्रदर्शन सचेत करने के लिए चाहता है नीचे जोड़े से ज फ़ाइल,
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message"
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
और यह के प्रतिनिधि विधि है जो UItextField
किस इनपुट-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"%@", [alertView textFieldAtIndex:0].text);
}
- 1. UIAlertView?
- 2. uialertview
- 3. UIAlertView
- 4. UIAlertView
- 5. UIAlertView
- 6. UIALertView
- 7. UIAlertView
- 8. UIAlertView को
- 9. UIAlertView प्रतिनिधि
- 10. UIAlertView ब्लॉकिंग
- 11. अनुकूलित UIAlertView
- 12. एक UIAlertView
- 13. UIAlertView रद्द करें बटनटन
- 14. UIAlertView: UIAlertViewStyleSecureTextInput: संख्यात्मक कुंजीपटल
- 15. UIAlertView घटना क्लिक करें
- 16. UIView पॉपअप जैसे UIAlertView
- 17. UIAlertView अनियंत्रित विधि पर क्रैशिंग
- 18. UIAlertView पूरा होने हैंडलर ब्लॉक
- 19. UIAlertView ऐप्पल आईडी और पासवर्ड IAP
- 20. अजीब UIAlertView निजी विधि क्रैश _performPopup
- 21. आईफोन में वास्तव में मोडल UIAlertView?
- 22. आईएपी आईओएस UIAlertView रद्द करें बटन
- 23. UIAlertView में संदेशों को संरेखित कैसे करें?
- 24. UIAlertView से इनपुट कैसे प्राप्त करें?
- 25. [UIAlertView शो] कैसे काम करता है?
- 26. आईफोन ऐप में कस्टम UIAlertView कैसे बनाएं
- 27. आईफोन - फोकस प्रभाव (बस UIAlertView की तरह)
- 28. स्टैकिंग से एकाधिक UIAlertView को कैसे रोकें?
- 29. UIAlertView की UITextField पर ऑटोकापिटाइजेशन कैसे सेट करें?
- 30. एकाधिक UIAlertView; प्रत्येक अपने बटन और क्रियाओं के साथ
मुझे लगता है कि एप्पल को हतोत्साहित रिटर्न अपने दृष्टिकोण। – shajem