Skip to content
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

Fixed crash TabBar changing index when tapThrough is enabled #158

Open
wants to merge 2 commits into
base: master
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change Log
==========
Version 0.9.0 *(2022-08-01)*
--------------------------------
* Supported new overload for setTargetView for UITabBarController item to fix the issue #118

Version 0.8.0 *(2021-03-25)*
--------------------------------
* Add the feature that is able to "Skip" showcase
Expand Down
2 changes: 1 addition & 1 deletion MaterialShowcase.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MaterialShowcase'
s.version = '0.8.0'
s.version = '0.9.0'
s.summary = 'An elegant and beautiful showcase for iOS apps.'

s.description = <<-DESC
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ brew install carthage

To integrate MaterialShowcase into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl
github "aromajoin/material-showcase-ios" ~> 0.8.0
github "aromajoin/material-showcase-ios" ~> 0.9.0
```

Run `carthage update` to build the framework and drag the built `MaterialShowcase.framework` into your Xcode project.
Expand Down Expand Up @@ -86,6 +86,8 @@ By default, tapping a showcase's target does not perform it's predefined action.
showcase.setTargetView(barButtonItem: barItem, tapThrough: true)
// UITabBar item
showcase.setTargetView(tabBar: tabBar, itemIndex: 0, tapThrough: true)
// UITabBarController
showcase.setTargetView(tabBarController: tabBarViewController, itemIndex: 0, tapThrough: true)
```

### Handle showcase status
Expand Down
16 changes: 16 additions & 0 deletions Sources/MaterialShowcase/MaterialShowcase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ extension MaterialShowcase {
}
}

@objc public func setTargetView(tabBarController: UITabBarController, itemIndex: Int, tapThrough: Bool = false) {
let tabBar = tabBarController.tabBar

let tabBarItems = orderedTabBarItemViews(of: tabBar)
if itemIndex < tabBarItems.count {
targetView = tabBarItems[itemIndex]
targetTintColor = tabBar.tintColor
backgroundPromptColor = tabBar.tintColor
if tapThrough {
onTapThrough = { tabBarController.selectedIndex = itemIndex}
}
} else {
print ("The tab bar controller item index is out of range")
}
}

/// Sets a UITableViewCell as target
@objc public func setTargetView(tableView: UITableView, section: Int, row: Int) {
let indexPath = IndexPath(row: row, section: section)
Expand Down