Skip to content

Commit e200a8f

Browse files
committed
Improve section "Close the tip"
Improve code examples to give context about where the code to close the tip have to be added in UIKit.
1 parent 04e17b9 commit e200a8f

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

en/tutorials/tipkit.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,28 @@ In the method, provide a reason why you closed the tip:
261261
- `.displayCountExceeded` - the tip has been shown the maximum number of times
262262
- `.tipClosed` - the user has clearly closed the tip
263263

264-
In UIKit, you need to add code for the cross. For `popover`-tip, close the controller:
264+
In UIKit, you need to add code for the cross.
265+
For `popover`-tip, close the controller:
265266

266267
```swift
267-
if presentedViewController is TipUIPopoverViewController {
268-
dismiss(animated: true)
268+
if shouldDisplay {
269+
...
270+
} else {
271+
if presentedViewController is TipUIPopoverViewController {
272+
dismiss(animated: true)
273+
}
269274
}
270275
```
271276

272277
For the `inline`-tip, we remove the view:
273278

274279
```swift
275-
if let tipView = view.subviews.first(where: { $0 is TipUIView }) {
276-
tipView.removeFromSuperview()
280+
if shouldDisplay {
281+
...
282+
} else {
283+
if let tipView = view.subviews.first(where: { $0 is TipUIView }) {
284+
tipView.removeFromSuperview()
285+
}
277286
}
278287
```
279288

ru/tutorials/tipkit.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,28 @@ inlineTip.invalidate(reason: .actionPerformed)
261261
- `.displayCountExceeded` - подсказку показали максимальное количество раз
262262
- `.tipClosed` - пользователь явно закрыл подсказку
263263

264-
В UIKit для крестика нужно дописать код. Для `popover`-подсказки закрываем контроллер:
264+
В UIKit для крестика нужно дописать код.
265+
Для `popover`-подсказки закрываем контроллер:
265266

266267
```swift
267-
if presentedViewController is TipUIPopoverViewController {
268-
dismiss(animated: true)
268+
if shouldDisplay {
269+
...
270+
} else {
271+
if presentedViewController is TipUIPopoverViewController {
272+
dismiss(animated: true)
273+
}
269274
}
270275
```
271276

272277
Для `inline`-подсказки удаляем вью:
273278

274279
```swift
275-
if let tipView = view.subviews.first(where: { $0 is TipUIView }) {
276-
tipView.removeFromSuperview()
280+
if shouldDisplay {
281+
...
282+
} else {
283+
if let tipView = view.subviews.first(where: { $0 is TipUIView }) {
284+
tipView.removeFromSuperview()
285+
}
277286
}
278287
```
279288

0 commit comments

Comments
 (0)