Comments (6)
@finlayjn thanks for your help. I fixed the issue.
from pagingkit.
@longunidev I'm sorry for the late reply. Could you show me the code snippet?
from pagingkit.
Just ran into the same issue. My code is very closely based on the Reloadable example, but I can send some if it helps. For me, the issue seems to arise from adding and removing view controllers from the data source. I implemented the following workarounds:
Reset the underline when updating the data source:
var dataSource = [(menu: String, content: UIViewController)]() {
didSet {
menuViewController?.reloadData()
contentViewController?.reloadData()
menuViewController?.focusView.subviews.forEach {$0.removeFromSuperview()}
menuViewController?.registerFocusView(view: UnderlineFocusView())
}
}
Scrolling away before removing a page also seems to help:
let closingIndex = menuViewController?.currentFocusedIndex
// Scroll to next page to the left if closing the rightmost page
if closingIndex == dataSource.count - 1 && dataSource.count > 1 {
menuViewController?.scroll(index: closingIndex! - 1, animated: true)
contentViewController?.scroll(to: closingIndex! - 1, animated: true)
// Otherwise, scroll to next page to the right
} else if dataSource.count > 1 {
menuViewController?.scroll(index: closingIndex! + 1, animated: true)
contentViewController?.scroll(to: closingIndex! + 1, animated: true)
menuViewController?.scroll(index: closingIndex!, animated: false)
contentViewController?.scroll(to: closingIndex!, animated: false)
}
dataSource.remove(at: (closingIndex)!)
from pagingkit.
@finlayjn Thanks. I'm going to try to reproduce the issue.
from pagingkit.
@finlayjn I couldn't reproduce the issue with MenuReloadableViewController. Could you give me any additional information?
from pagingkit.
Sure. Like I said I think it's an issue with updating the data source. More specifically, it seems to occur when the data source is empty and an item is added. Here's the changes I made to reproduce the issue in the MenuReloadableViewController example in the sample project:
Change "menus" constant to a variable and leave it empty to begin.
var menus: [String] = []
Add this line to the reloadButtonDidTap action before updating dataSource.
self.menus.append("Menu")
Run the app and press the Reload button. The first menu item that appears will not be aligned with its underline.
from pagingkit.
Related Issues (20)
- How to insert image inside menu items so that every menu item will have image and text. HOT 1
- contentViewController won't scroll to specific page programmatically HOT 1
- Update Cocoapods with 1.11.2? HOT 4
- Support for iOS 12.0 HOT 2
- v1.12.0: Appearing vc's viewWillAppear is called after scrolling has ended HOT 1
- deleting a row from a tableView HOT 1
- Swift Package Manager HOT 2
- menuViewController.cellAlignment = .center HOT 2
- UITableViewAlertForLayoutOutsideViewHierarchy warning HOT 1
- Is it possible to incorporate into Table View Cell? HOT 1
- Carthage update command fails in Xcode12.1 HOT 1
- How can I set default page index When init?
- Switch page programmatically HOT 1
- Without Storyboard HOT 1
- Can I preload all contentViewControllers? HOT 1
- How to customise PagingMenuViewController overlay title HOT 1
- How to install version 1.18.2? HOT 1
- Add Header content view
- How to create a dynamically adjustable PagingContentViewController's height?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pagingkit.