2012-01-18 10 views
11

मैं UIAlertView के संदेश में एक यूआरएल का एक क्लिक करने योग्य लिंक जोड़ना चाहता हूं। जैसे कि जब उपयोगकर्ता अलर्ट व्यू देखता है, तो वे संदेश के अंदर लिंक पर स्पर्श कर सकते हैं। वैकल्पिक रूप से वे ठीक बटन पर क्लिक करके आगे जा सकते हैं।UIAlertView के संदेश में यूआरएल के लिए टच करने योग्य यूआरएल लिंक कैसे जोड़ें?

ऐसा करना संभव है? कैसे?

उत्तर

7

एक कस्टम तरीका जो आप कोशिश कर रहे हैं उसे लागू करने के लिए एक कस्टम अलर्ट व्यू के माध्यम से है।

ऐसे कई दृष्टिकोण हैं जिन्हें आप ले सकते हैं। एक UIAlertView subclassing है और यहां आप एक छोटा ट्यूटोरियल पा सकते हैं: Subclass UIAlertView। अपने उप-वर्ग में आप स्पर्श-सक्षम टेक्स्ट को लागू करने के लिए किसी भी तरह से अलर्ट बना सकते हैं। ऐसा करने के लिए this tutorial पर एक नज़र डालें।

1

मैं आज इस समस्या में भाग गया, मुझे अपने अलर्ट व्यू में क्लिक करने योग्य फोन नंबर और पते की आवश्यकता थी और कुछ समय के लिए कस्टम अलर्ट विचार प्रश्न से बाहर हो गए थे।

कुछ शोध के बाद ऐसा लगता है कि आप एक चेतावनी में एक टेक्स्टव्यू जोड़ सकते हैं जो मेरी समस्या को हल करने लग रहा था। (: C# का उपयोग कर Xamarin साथ टिप्पणी):

// create text view with variable size message 
UITextView alertTextView = new UITextView(); 
alertTextView.Text = someLongStringWithUrlData; 

// enable links data inside textview and customize textview 
alertTextView.DataDetectorTypes = UIDataDetectorType.All; 
alertTextView.ScrollEnabled = false; // is necessary 
alertTextView.BackgroundColor = UIColor.FromRGB(243, 243, 243); // close to alertview default color 
alertTextView.Editable = false; 

// create UIAlertView 
UIAlertView Alert = new UIAlertView("Quick Info", "", null, "Cancel", "OK"); 
Alert.SetValueForKey(alertTextView, (Foundation.NSString)"accessoryView"); 

// IMPORTANT/OPTIONAL need to set frame of textview after adding to subview 
// this will size the text view appropriately so that all data is shown (also resizes alertview 
alertTextView.Frame = new CoreGraphics.CGRect(owner.View.Center, alertTextView.ContentSize); 
Alert.Show(); 
+0

"मालिक" क्या है ये मेरा दृष्टिकोण है कि गतिशील स्केलिंग alertviews के लिए अनुमति देता है? अंतिम पंक्ति के लिए दूसरा। रास्ते से महान काम करता है! – stepheaw

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