Skip to content

Improve section "Close the tip" #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions en/tutorials/tipkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,28 @@ In the method, provide a reason why you closed the tip:
- `.displayCountExceeded` - the tip has been shown the maximum number of times
- `.tipClosed` - the user has clearly closed the tip

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

```swift
if presentedViewController is TipUIPopoverViewController {
dismiss(animated: true)
if shouldDisplay {
...
} else {
if presentedViewController is TipUIPopoverViewController {
dismiss(animated: true)
}
}
```

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

```swift
if let tipView = view.subviews.first(where: { $0 is TipUIView }) {
tipView.removeFromSuperview()
if shouldDisplay {
...
} else {
if let tipView = view.subviews.first(where: { $0 is TipUIView }) {
tipView.removeFromSuperview()
}
}
```

Expand Down
19 changes: 14 additions & 5 deletions ru/tutorials/tipkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,28 @@ inlineTip.invalidate(reason: .actionPerformed)
- `.displayCountExceeded` - подсказку показали максимальное количество раз
- `.tipClosed` - пользователь явно закрыл подсказку

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

```swift
if presentedViewController is TipUIPopoverViewController {
dismiss(animated: true)
if shouldDisplay {
...
} else {
if presentedViewController is TipUIPopoverViewController {
dismiss(animated: true)
}
}
```

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

```swift
if let tipView = view.subviews.first(where: { $0 is TipUIView }) {
tipView.removeFromSuperview()
if shouldDisplay {
...
} else {
if let tipView = view.subviews.first(where: { $0 is TipUIView }) {
tipView.removeFromSuperview()
}
}
```

Expand Down