iOS Swift 4 before loading content - ios

I build chat app using Firebase API right now. I wan't to make preload icons like on facebook screenshot. I thought i can create empty images and label fields and fill them after content loaded, but i don't know how to check if all data loaded from DB. How i can do that in correct way?
This is where i want to place objects

Install ListPlaceholder this lib.
import ListPlaceholder
To show the loader, start showing this from start
tableView.showLoader()
To hide the loader, end showing after data has been loaded
tableView.hideLoader()
Please refer this may get help.
https://github.com/malkouz/ListPlaceholder

Facebook has it's own library called Shimmer. To use this on tableview, you can follow this StackOverflow question answer.
You'll just have to create the UIView you want to animate and above that you'll have to add your FBShimmeringView. At the end set shimmeringView.shimmering = true to start shimmering

To hide the loading use tableView.hideLoader()
ListPlaceholder helped me to resolve the issue. All that I did was added the ListLoader.swift file to my project and added tableView.reloadData(), tableView.showLoader() in viewDidAppear in the tableView where I wanted to show loading.
( ListLoader.swif uses visibleCells to determine the number of rows on which the loading should be shown. In my applications, visibleCell's count was incorrect on calling tableView.showLoader() method in viewDidLoad )

Related

ios - loading decoupled view from nib file

I am having difficulty with something that seems to be trivial. I am following this project https://github.com/eppz/iOS.Blog.UIView_from_Xib and trying to implement the decoupled way of loading a view from a nib file. I was not able to get the desired result in my app (nothing shows up and I get no crashes either) so I did the following:
I took the project from Github https://github.com/eppz/iOS.Blog.UIView_from_Xib
I then proceeded to duplicate the files in the "decoupled" group and name it something trivial like "decoupled2". Basically I am creating a whole new class that stands on its own with its own nib file.
I then changed all of the internal tags and class references. Then I made sure that all of the new references were pointing to this new class.
At this point I added a 6th button to the main VC and made sure to call the right method for my new "decoupled2" class when this 6th button is pressed.
PROBLEM: Everything runs but the view from nib does not show up. Debugging view hierarchy shows nothing. Clicking the 5th button still works, so I didn't break the existing code. Why won't the newly created nib file show up?
This seems rather simple, just duplicate what already works in a project that already works and it will work...or not. What am I missing? Thank you for your help.
I have spent a few days on the problem already. Lots of research but nothing of use so far.
I re-did the task and it worked this time.
Maybe restarting Xcode 8.0 was the key or something else that is under the hood.

App crashes on return from some share plugins of activityViewController

I've got a TableViewController with static table; one of it's cells houses an UIView named graphArea. The view renders a chart, it's background and an axis line - all inside it's drawRect(). There are also two another views (sunView & markerView), that are made with Interface Builder and used for chart dynamics (moving marker line and point on touch events).
All worked buttery smooth until I've implemented and tried to test a share button, that employs the ordinary activityViewController mechanism.
The magic begins, when one from a couple of share activities, whose share plugin window takes the full screen, is finished (no matter whether sharing succeeded or cancelled). The app crashes.
Discovery using debugger made apparent to me, that the crash happens, because some views, including graphArea, sunView, markerView are nil after return from sharing screen.
Only some of fullscreen share plugins (like preinstalled Mail and Messages, or, in my case, "Download to DropBox" action) lead app to crash. Other fullscreen share plugins do not (tested Telegram, WhatsApp, Skype). No one of those non-fullscreen plugins has ever caused crash (Evernote, Twitter, 2Do etc.).
It looks like graphArea, sunView, markerView are deallocated from memory when "malicious" share plugins take full screen. I haven't figured out, why.
Here's some debug info:
The traceback and assembly of fatalErrorMessage.
The next screenshot shows a part of controller code and properties, that are nil on return from share plugin (gray selection). And yes, they were all non-nil before.
Please, help me! Thank you in advance!
Thank you, Palpatim. My friend also pointed me at the same thing: I've put graphArea.removeFromSuperview() in viewDidDisappear(), and this caused the exception after share plugins, that have .presentationStyle = fullScreen. So at the point, when the app is to show again, there is no more graphArea in on the tableView.

UICollectionview with uidynamics reload data issue

I have been working on an app that uses UIDynamics in UICollectionView. I have watched Apple WWDC video and have also tried this sample app in Github.
However, I had this weird problem: When my app launches, I set the number of items for my collection view to 0, the app needs to download something from the server then populate the collection view on the main thread. Weirdly, it's (kinda) reloaded, but not showing anything. I tried on the sample app from Github and it has the same issue as well.
However, if I remove this part:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect{
return [self.dynamicAnimator itemsInRect:rect];
}
The CollectionView will show what I want but without the UIDynamics.
I hope the illustration on my problem is easy to understand. Any help will be much appreciated. My guess is I shouldn't use reloaddata.

MonoTouch - Refresh TableView

I am writing a news application for iOS using MonoTouch. The data comes via an OData web sevice.
I have a singleton class called NewsFactory which is responsible for querying the OData feed. Now in the ViewDidLoad method I am retrieving the list of news articles and binding it to the table view.
However - I am not sure how to refresh this every time the app is launched. I don't care much for "pull to refresh". All I want to make sure is that every time the app is launched (from scratch or activated again) that the call to the web service is made to make sure I show the latest info.
In addition, I want to cover for the scenario where the network connectivity is lost when the app is launched and I notify the user. The use closes the app (suspend) and let's say the network connectivity returns - If the user opens the app again, I would like to make sure that I show the latest news articles.
I am building the view hierarchy programmatically. I have navigation controllers and a tab bar controller with 5 tabs.I am targeting iOS 5.
I tried playing with OnActivated and ViewWillAppear and they don't do exactly what I need to do. This is a very common need for any iOS app so there must be a solution - I am new to this so any help is appreciated.
Well you have to think, in general, if you call a method that loads from one source (let's say a text file that has data in it), then you change up the source (change text data), but call the same method when the class is loaded, then the new data will appear when the new class is loaded.
Like for example:
- (void) loadView {
NSString *testString = [NSString stringWithContentsOfFile:filePath];
textView.text = testString;
}
This example shows the setting of text in a file to a UITextView instance. If you load it the first time and the file contained the contents of "Hi", then the textView will say hi. If you change it, then call the same method, then it will show your changed text the second time you load the app.
The point is that if you change data, then call the same method, then you'll see a difference. Unless you're working with a database.
I'd give you a better example if you provide sample code.
EDIT: Not sure if your custom class comes with this function, but it is included in the regular UITableView class:
[tableView reloadData];
You can call that after your array changes internally.

How to call LazyTableImages in my own project

I am new to IOS development, and I would like to use the LazyTableImages sample in my project. I have main screen displaying a list of menus. What i want to achieve is that when a user clicks a menu on the main screen, it will start a new screen which calls the LazyTableImages code and downloads the images.
But i have no idea how to do that.Because in the sample, the screen with the images is the first window, and in my project, it is not.It seems that I will need to move the LazyTableAppDelegate.h and LazyTableAppDelegate.m to the my own delegate file AppDelegate.h and AppDelegate.m files but i didnt get any luck doing that. Can anyone shed any light how should i make the change? Is there any sample code i can refer how to call one project in the other?
http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html
this links solve your problems.
1) [HJCache][1]
2) [Video Part1][2]
3) [Video Part2][3]

Resources