#UIActivityIndicatorView
Explore tagged Tumblr posts
Text
Customise ActivityIndicator | Swift 5.2 | Xcode 11
Customise ActivityIndicator | Swift 5.2 | Xcode 11
Hi Buddy,
In this swift tutorial I discuss the topic of Customise ActivityIndicator out of your UIViews. This will make your code much more readable, and keep those UIViewController small.
You can use this LoadingIndicator for any other Views. That makes sense to users what was going on right now in this UI Element.
Once you implemented it will help for your entire project. Because of…
View On WordPress
#Code with kathiresan#Code with ktrkathir#Indicator#Ios#iOS 12#iOS 13#kathiresan#KathiresanMurugan#ktr#ktrkathir#loader#NVActivityIndicator#spinner#swift#UIActivityIndicatorView#Xcode#Xcode 11#XCode 11.2
0 notes
Text
WebServices Using Swift
// WebServiceClass.swift
// webService
// Created by Bhushan on 24/07/18.
// Copyright © 2018 Bhushan. All rights reserved.
import UIKit
typealias completionService = (_ data: Data, _ response: URLResponse, _ error: Error?) -> Void
class WebServiceClass: NSObject {
override init() {
super.init()
}
func sendGetRequest(_ dictionary: [AnyHashable: Any], withMethod method: String, withCompletion block:@escaping completionService) {
let sessionConfig = URLSessionConfiguration.default
let session = URLSession(configuration: sessionConfig, delegate: nil, delegateQueue: nil)
let request = NSMutableURLRequest(url: URL(string: method)!)
request.httpMethod = "GET"
let dataTask = session.dataTask(with: request as URLRequest) { (data,response,error) in
if error != nil{
print(error!.localizedDescription)
if block != nil {
let tempData : Data = Data()
let tempResponse : URLResponse = URLResponse()
block(tempData, tempResponse, error)
} }
else {
if block != nil {
block(data!, response!, error)
}
}
}
dataTask.resume()
}
func sendPostRequest(_ dictionary: [AnyHashable: Any], withMethod method: String, withCompletion block: @escaping completionService) {
let sessionConfig = URLSessionConfiguration.default
let session = URLSession(configuration: sessionConfig, delegate: nil, delegateQueue: nil)
let request = NSMutableURLRequest(url: URL(string: method)!)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let postData: Data? = try? JSONSerialization.data(withJSONObject: dictionary, options: [])
request.httpBody = postData
// request.httpBody = postData
let dataTask = session.dataTask(with: request as URLRequest) { (data,response,error) in
if error != nil{
print(error!.localizedDescription)
if block != nil {
let tempData : Data = Data()
let tempResponse : URLResponse = URLResponse()
block(tempData, tempResponse, error)
}
// return
}
else {
if block != nil {
block(data!, response!, error)
}
}
}
dataTask.resume()
}
***Important Links***
http://images.nuptial.me/ProfilePics/Wedding1/ProfilePicForPartner1.png http://images.nuptial.me/WedsiteImages/Wedsite1/WedsiteImageForWedding1/WedsiteImage11198175568T1530284086.jpg
http://aerialyoga_api.dedicatedresource.net/login email, password , device_type
http://aerialyoga_api.dedicatedresource.net/about-us
***To Download Image***
func downloadImage(url: URL, withImage imageView:UIImageView) {
print("Download Started")
// var actInd: UIActivityIndicatorView = UIActivityIndicatorView()
// showActivityIndicatory(imgView: imageView, and: actInd)
getDataFromUrl(url: url) { (data, response, error) in
guard error == nil else { return }
print(response.suggestedFilename ?? url.lastPathComponent)
print("Download Finished")
DispatchQueue.main.async() { () -> Void in
// actInd.stopAnimating()
imageView.image = UIImage(data: data)
}
}
}
***Hints About Post Method***
func inviteeLogin(){
if isValidated(){
showLoader(OnView: view)
let serviceHandler: ServiceHandler = ServiceHandler()
let postString = "Invitees[INVITEE_EMAIL]=\(txtEmailField.text!)&Invitees[PIN_CODE]=\(txtEnterCode.text!)"
serviceHandler.sendPostRequestWithString(postString, withMethod: "http://rest.nuptial.me/wedsite-couple/login", withCompletion:{(_ data: Data, _ response: URLResponse, _ error: Error?) -> Void in
if error == nil {
do{
let dic = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String : Any]
if ((dic?["status"] as! Int) == 1) {
DispatchQueue.main.async(execute: {() -> Void in
self.dismissLoader()
print(dic!)
let dict = dic!["data"] as! [String:AnyObject]
NPConstants.defaults.set(dict["INVITEE_ID"], forKey: "inviteeId")
NPConstants.defaults.synchronize()
let controller = self.storyboard?.instantiateViewController(withIdentifier: "NPInviteeVC") as! NPInviteeVC
self.navigationController?.pushViewController(controller, animated: true)
})
}
else
{
DispatchQueue.main.async(execute: {() -> Void in
print(dic!)
self.dismissLoader()
})
}
}
catch{
self.dismissLoader()
print("catch block")
print("Error with Json: \(error)")
}
}
else {
DispatchQueue.main.async(execute: {() -> Void in
self.dismissLoader()
})
}
})
}
}
0 notes
Text
Top 10 Libraries for iOS Developers
Update note: This tutorial has been updated by Kishin Manglani. The original tutorial was written by Marcelo Fabri.
It’s no secret that third-party iOS developer libraries can save precious time when you’re doing developing apps. The iOS open-source community is quite active, and we all know that leveraging libraries is a must when developing an app on your own. Each library offers different tools that you can use to enhance your next iPhone app, including working around some of the most obnoxious constraints of Swift and Objective-C.
Selection Criteria
Rating iOS developer libraries is a rather subjective proposition. What makes one library “better” than the next? When libraries solve such a vast range of problems and no two are alike, it’s difficult to make logical comparisons and rank them in order of best to worst.
Fortunately, CocoaPods, a popular Swift and Objective-C dependency manager, collects anonymous stats when users install packages. I scraped its statistics site to find out which open-source packages are most popular right now, rather than polling my colleagues or trying to rate them for myself, and below are the results!
1. AFNetworking
AFNetworking is an Objective-C networking library for iOS, macOS and tvOS. It is a robust library that has been around for many years. From basic networking to advanced features such as Network Reachability and SSL Pinning, AFNetworking has it all. It is one of the most popular iOS libraries of all time with almost 50 million downloads.
AFNetworking: http://ift.tt/xQh6e6
2. SDWebImage
SDWebImage is an asynchronous image downloader with caching. It has handy UIKit categories to do things such as set a UIImageView image to an URL. While networking has become a little bit easier in Cocoa over the years, the basic task of setting an image view to an image using an URL hasn’t improved much. SDWebImage helps ease a lot of pain, so that’s why it’s so popular with iOS app developers.
SDWebImage: http://ift.tt/Hf9tea
3. Alamofire
Alamofire is AFNetworking’s successor but is written in Swift. You might be wondering why there are two different networking libraries in the upper echelon of this list, but I assume it’s due to the fact that networking libraries are just extremely useful for iOS app development. The two libraries share a similar feature set, with the main difference being the language in which they are written.
If you are starting a brand new Swift project, my recommendation is to use Alamofire so that your core networking library is consistent with your own source code. Otherwise, both AFNetworking and Alamofire are great options.
Alamofire: http://ift.tt/1ABz8c0
4. MBProgressHUD
MBProgressHUD is another useful library that fills a big hole in UIKit. This popular iOS developer library provides a class that displays a heads-up display (HUD) with a spinner, text, or images to show loading, progress, success/failure, or any other alerts to the user. Since iOS has long lacked a native HUD component, I don’t need to tell you how helpful such features are!
MBProgressHUD: http://ift.tt/qVAFSc
5. Masonry
Masonry is a lightweight framework that makes wrestling with AutoLayout much less strenuous through simpler syntax. It provides its own chainable DSL that makes AutoLayout code more concise and readable. It also provides several helper methods for common layouts that will shorten over a dozen lines of code with AutoLayout to a single line. For example, if you want to set the edges of a UITableView to the edges of its superview, you can use this: make.edges.equalTo(self);
Masonry: http://ift.tt/1JMLpgH
6. SwiftyJSON
SwiftyJSON improves your life when it comes to handling JSON in Swift. Parsing JSON with Swift can be tricky due to type casting issues that make it difficult to deserialize model object, amd it may require a bunch of nested if statements. SwiftyJSON makes all of it quite simple to do. It’s also the second-most popular Swift library.
SwiftyJSON: http://ift.tt/Z2t6lA
7. SVProgressHUD
SVProgressHud is another HUD library for iOS and tvOS. The API is a bit simpler than MBProgressHUD because it creates a singleton, so you just need to call show and hide when using it. You can also customize the HUD with text, an image, or a progress indicator. Again, there is definitely a need for this when developing apps, and it is a useful alternative to MBProgressHUD.
SVProgressHUD: http://ift.tt/1Q27fRk
8. MJRefresh
MJRefresh offers you an easy way to add pull-to-refresh functionality to a UITableView. Unfortunately, the standard UIRefreshControl disappoints when it comes to customization options, so MJRefresh is a great stand-in that allows you to add text, an animation or even a UIView. You can also add pull-to-refresh actions in a block or closure, making it even easier to implement than the native UIActivityIndicatorView.
MJRefresh: http://ift.tt/1FVgXzw
9. CocoaLumberjack
CocoaLumberjack is a simple but powerful logging framework for all your logging needs. If you want to do more than NSLog or print, CocoaLumberjack can help. You can do remote logging, log to a local file, write to multiple loggers, and create different log levels. Ever had to reproduce an elusive bug, or needed to get a better grasp on some user behavior? CocoaLumberjack is very helpful in these cases.
CocoaLumberJack: http://ift.tt/1auCfmI
10. Realm
Realm is an enticing, cross-platform alternative to Core Data when it comes to persistence. It’s easier to work with than Core Data, as well as faster, and you even get a data browser to explore Realm database files. In case you need another reason to love Realm, this popular library for iOS app development recently launched a platform to sync data between apps in real-time.
If you need to do any data persistence, I’d definitely recommend checking out Realm as an alternative to Core Data.
Realm: http://ift.tt/W7Pfhw
We even have a couple of Realm video tutorial series to help you get started with Realm!
Beginning Realm on iOS
Intermediate Realm on iOS
Honorable Mentions
Only two out of the most popular iOS developer libraries are written in Swift! Hard to believe when you’re living, breathing, and eating Swift. Here are a couple of Swift libraries that didn’t quite make the top 10, according to the data I pulled, but are worthy of your attention.
SnapKit
SnapKit is another iOS library that simplifies AutoLayout simpler, and is similar to Masonry (above). In fact, SnapKit is a successor of Masonry that happens to be written in Swift. The authors of the library recommend that if you are starting a Swift project go with SnapKit, but if you are using Objective-C then go with Masonry.
SnapKit: http://ift.tt/1Ghmfc7
Kingfisher
Similar to SDWebImage above, Kingfisher is a library for downloading and caching images that is written purely in Swift. It includes extensions for UIImageView and UIButton, which makes it more obliging. You can also add a placeholder image that should show while the actual image is downloading.
Kingfisher: http://ift.tt/1zbWxhh
Many of the leading iOS libraries continue to be written for Objective-C, but I’m seeing new Swift libraries emerging regularly. Almost daily at times. The trend is shifting toward Swift. You’re seeing so many Objective-C libraries on this list years after Swift’s release because they are tried and true and trusted in tens of thousands of apps.
As we close out 2017, these are the most popular libraries according to the number of installs.
You can pull the data for yourself from this link: http://ift.tt/2jXMC01.
Just swap Alamofire with whatever library you want to query, and remember that it is case-sensitive.
You should have a good idea of the best libraries to make your iOS app development experience a little smoother. Think I missed a great library? Or want to talk about your experiences with these libraries? Let’s talk about it in the forums.
The post Top 10 Libraries for iOS Developers appeared first on Ray Wenderlich.
Top 10 Libraries for iOS Developers published first on http://ift.tt/2fA8nUr
0 notes
Text
Adding a UIActivityIndicator on UINavigationBar
The accepted answer here made it work:
http://stackoverflow.com/questions/1719533/add-uiactivityindicatorview-into-uibarbutton
0 notes
Text
UIActivityIndicatorView over an UIButton
Did you know that putting an UIActivityIndicatorView over a UIButton, all touch events are blocked by the spinner?
If you do the same with a UILabel or UIImageView, all events are forwarded to the button (its superview), like I (and you) expect. But with UIActivityIndicatorView this is not the behaviour you get. All these classes are extensions of UIView, so why they work differently?
The key difference is that the UIActivityIndicatorView is animated. When you have an animated view, iOS changes its userInteractionEnabled property to YES to prevent interactions (and interruptions) from the user with that view, during the animation phase.
How to fix that? Just set userInteractionEnabled to NO on the spinner, so all the touch events are forwarded again to the spinner superview (the button in my case) and everything works like I expect.
Here is the example code
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[spinner startAnimating];
[spinner setUserInteractionEnabled:NO]; // setting UserInteractionEnable to NO, any touch events are forwarded to the superview (the button)
spinner.center = CGPointMake(20, 18);
[self addSubview:spinner];
Bug fixed. Let's move on...
0 notes
Text
Singleton class for Loading indicator swift
Singleton class for Loading indicator swift
import Foundation import UIKit class LoadingIndicator: UIView { /// ActivityIndicator let loader = UIActivityIndicatorView() /// Shared Instance static let shared: LoadingIndicator = { let instance = LoadingIndicator() return instance }() override init(frame: CGRect) { super.init(frame: frame) prepared() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been…
View On WordPress
#10.0#10.2#11.0#11.2#8.1#8.2#8.3#8.4#9.0#9.1#APP#Apple#Developer#Developers#Development#forum#how to make an ios app#Indicator#Ios#iOS 11#iOS 11.2#iOS 8#iOS 8.1#iOS7#iOS7.1#iPad#iPhone#iPod#kathir#ktr
0 notes