@@ -134,38 +134,40 @@ class NFXDetailsController_iOS: NFXDetailsController, MFMailComposeViewControlle
134134 scrollView. autoresizesSubviews = true
135135 scrollView. backgroundColor = UIColor . clear
136136
137- var textLabel : UILabel
138- textLabel = UILabel ( )
139- textLabel. frame = CGRect ( x: 20 , y: 20 , width: scrollView. frame. width - 40 , height: scrollView. frame. height - 20 ) ;
140- textLabel. font = UIFont . NFXFont ( size: 13 )
141- textLabel. textColor = UIColor . NFXGray44Color ( )
142- textLabel. numberOfLines = 0
143- textLabel. attributedText = content
144- textLabel. sizeToFit ( )
145- textLabel. isUserInteractionEnabled = true
146- scrollView. addSubview ( textLabel)
137+ var textView : UITextView
138+ textView = UITextView ( )
139+ textView. frame = CGRect ( x: 20 , y: 20 , width: scrollView. frame. width - 40 , height: scrollView. frame. height - 20 ) ;
140+ textView. backgroundColor = UIColor . clear
141+ textView. font = UIFont . NFXFont ( size: 13 )
142+ textView. textColor = UIColor . NFXGray44Color ( )
143+ textView. isEditable = false
144+ textView. attributedText = content
145+ textView. sizeToFit ( )
146+ textView. isUserInteractionEnabled = true
147+ textView. delegate = self
148+ scrollView. addSubview ( textView)
147149
148150 let lpgr = UILongPressGestureRecognizer ( target: self , action: #selector( NFXDetailsController_iOS . copyLabel) )
149- textLabel . addGestureRecognizer ( lpgr)
151+ textView . addGestureRecognizer ( lpgr)
150152
151153 var moreButton : UIButton
152- moreButton = UIButton . init ( frame: CGRect ( x: 20 , y: textLabel . frame. maxY + 10 , width: scrollView. frame. width - 40 , height: 40 ) )
154+ moreButton = UIButton . init ( frame: CGRect ( x: 20 , y: textView . frame. maxY + 10 , width: scrollView. frame. width - 40 , height: 40 ) )
153155 moreButton. backgroundColor = UIColor . NFXGray44Color ( )
154156
155157 if ( ( forView == EDetailsView . request) && ( self . selectedModel. requestBodyLength > 1024 ) ) {
156158 moreButton. setTitle ( " Show request body " , for: . init( ) )
157159 moreButton. addTarget ( self , action: #selector( NFXDetailsController_iOS . requestBodyButtonPressed) , for: . touchUpInside)
158160 scrollView. addSubview ( moreButton)
159- scrollView. contentSize = CGSize ( width: textLabel . frame. width, height: moreButton. frame. maxY + 16 )
161+ scrollView. contentSize = CGSize ( width: textView . frame. width, height: moreButton. frame. maxY + 16 )
160162
161163 } else if ( ( forView == EDetailsView . response) && ( self . selectedModel. responseBodyLength > 1024 ) ) {
162164 moreButton. setTitle ( " Show response body " , for: . init( ) )
163165 moreButton. addTarget ( self , action: #selector( NFXDetailsController_iOS . responseBodyButtonPressed) , for: . touchUpInside)
164166 scrollView. addSubview ( moreButton)
165- scrollView. contentSize = CGSize ( width: textLabel . frame. width, height: moreButton. frame. maxY + 16 )
167+ scrollView. contentSize = CGSize ( width: textView . frame. width, height: moreButton. frame. maxY + 16 )
166168
167169 } else {
168- scrollView. contentSize = CGSize ( width: textLabel . frame. width, height: textLabel . frame. maxY + 16 )
170+ scrollView. contentSize = CGSize ( width: textView . frame. width, height: textView . frame. maxY + 16 )
169171 }
170172
171173 return scrollView
@@ -336,4 +338,25 @@ extension NFXDetailsController_iOS: UIActivityItemSource {
336338 }
337339}
338340
341+ extension NFXDetailsController_iOS : UITextViewDelegate {
342+
343+ func textView( _ textView: UITextView , shouldInteractWith URL: URL , in characterRange: NSRange ) -> Bool {
344+ let decodedURL = URL . absoluteString. removingPercentEncoding
345+ switch decodedURL {
346+ case " [URL] " :
347+ guard let queryItems = self . selectedModel. requestURLQueryItems, queryItems. count > 0 else {
348+ return false
349+ }
350+ let urlDetailsController = NFXURLDetailsController ( )
351+ urlDetailsController. selectedModel = self . selectedModel
352+ self . navigationController? . pushViewController ( urlDetailsController, animated: true )
353+ return true
354+ default :
355+ return false
356+ }
357+
358+ }
359+
360+ }
361+
339362#endif
0 commit comments