संक्षेप में, मैं @IBInspectable
संपत्ति बनाना चाहता हूं जो आपको स्टोरीबोर्ड में होने पर ड्रॉप डाउन मेनू में चीजों की सूची से चयन करने की अनुमति देता है। इसके अलावा यदि डिवाइडर बनाने और बेहतर तरीके से IBInspectables
व्यवस्थित करने का कोई तरीका है, तो मैं जानना चाहूंगा कि यह भी संभव है या नहीं। मेरे उदाहरण में, मैं फोन नंबर के लिए रेगेक्स स्ट्रिंग बनाना चाहता हूं ताकि जब मैं स्टोरीबोर्ड पर जाऊं तो मैं रेगेक्स स्ट्रिंग में प्रवेश करने के बजाय "फोन नंबर" आइटम को ड्रॉप डाउन मेनू में चुन सकता हूं।IBInspectable एक ड्रॉपडाउन और बेहतर संगठन बनाना
वर्तमान में मैंने TextField
को उपclassed है ताकि मैं regex (जिसे आप चित्र में देख सकें) जैसे IBInspectables
जोड़ सकें। जहाँ तक मुझे पता है, सूची (सरणियों) अभी तक समर्थित नहीं हैं
@IBDesignable public class FRM_TextField: UITextField {
@IBInspectable public var regex : String?
public var isValid : Bool{
if let unwrappedRegex = regex{
let applied_regex_expression = NSRegularExpression.regularExpressionWithPattern(unwrappedRegex, options: nil, error: nil)
let numberOfMatches = applied_regex_expression?.numberOfMatchesInString(text, options: nil, range: NSMakeRange(0, countElements(text)))
if(numberOfMatches > 0){
return true
}else{
return false
}
}
return false
}
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public override init(){
super.init();
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
}
रूप लोग यहां बाद में आने वाले के लिए, आप, सुधारने/कुछ BOOL गुण है कि उपयोगकर्ता को चालू और बंद टॉगल कर सकते हैं के साथ क्या कर सकता है। यह आदर्श नहीं है लेकिन यह एक विकल्प है। आपके प्रश्न के लिए – hhanesand
@ जोर्डन होचस्टेटर +1 क्या आपको इसके लिए समाधान मिला? – Rakesh