Displaying activity indicator to the right of tableview row












1















My tableview is having Disclosure indicator as an accessory item. The didSelectItem() call of this tableview cell performs an api call on background. So the view will need to wait until the response to show next page. I have to provide an activity indicator to the position of disclosure indicator. how it is possible like in ios settings page



func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Returns the cell value for each index
let cell = tableView.dequeueReusableCell(withIdentifier: TenantCell.identifier, for: indexPath) as! TenantCell
cell.populate(with: tenantList[indexPath.row])
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Api.domain = tenantList[indexPath.row].url!
sharedAFManager.getJsonData(api: Api.theme, completionHandler: { (response, statusCode) in
if let theme = response {
Api.logo = theme["logo"].stringValue
Constants.passwordRegx = theme["passwordRegex"].stringValue
self.performSegue(withIdentifier: Segue.login, sender: indexPath.row)
}
})
}


/// UITableview cell populating tenant informations
class TenantCell: UITableViewCell {

@IBOutlet weak var tenantImage: UIImageView!
@IBOutlet weak var tenantNameLabel: UILabel!
@IBOutlet weak var tenantUrlLabel: UILabel!

func populate(with tenant: Tenant) {
tenantNameLabel?.text = tenant.name
tenantUrlLabel?.text = tenant.url
tenantImage.image = UIImage(named: "breifcase")
}
}


Expected output










share|improve this question

























  • where is cellForRowAt method code? plz upload your full code

    – Pratik Prajapati
    Jan 1 at 6:40











  • Added cellForRowAt method to the code sample

    – Vaisakh KP
    Jan 1 at 6:50
















1















My tableview is having Disclosure indicator as an accessory item. The didSelectItem() call of this tableview cell performs an api call on background. So the view will need to wait until the response to show next page. I have to provide an activity indicator to the position of disclosure indicator. how it is possible like in ios settings page



func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Returns the cell value for each index
let cell = tableView.dequeueReusableCell(withIdentifier: TenantCell.identifier, for: indexPath) as! TenantCell
cell.populate(with: tenantList[indexPath.row])
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Api.domain = tenantList[indexPath.row].url!
sharedAFManager.getJsonData(api: Api.theme, completionHandler: { (response, statusCode) in
if let theme = response {
Api.logo = theme["logo"].stringValue
Constants.passwordRegx = theme["passwordRegex"].stringValue
self.performSegue(withIdentifier: Segue.login, sender: indexPath.row)
}
})
}


/// UITableview cell populating tenant informations
class TenantCell: UITableViewCell {

@IBOutlet weak var tenantImage: UIImageView!
@IBOutlet weak var tenantNameLabel: UILabel!
@IBOutlet weak var tenantUrlLabel: UILabel!

func populate(with tenant: Tenant) {
tenantNameLabel?.text = tenant.name
tenantUrlLabel?.text = tenant.url
tenantImage.image = UIImage(named: "breifcase")
}
}


Expected output










share|improve this question

























  • where is cellForRowAt method code? plz upload your full code

    – Pratik Prajapati
    Jan 1 at 6:40











  • Added cellForRowAt method to the code sample

    – Vaisakh KP
    Jan 1 at 6:50














1












1








1








My tableview is having Disclosure indicator as an accessory item. The didSelectItem() call of this tableview cell performs an api call on background. So the view will need to wait until the response to show next page. I have to provide an activity indicator to the position of disclosure indicator. how it is possible like in ios settings page



func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Returns the cell value for each index
let cell = tableView.dequeueReusableCell(withIdentifier: TenantCell.identifier, for: indexPath) as! TenantCell
cell.populate(with: tenantList[indexPath.row])
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Api.domain = tenantList[indexPath.row].url!
sharedAFManager.getJsonData(api: Api.theme, completionHandler: { (response, statusCode) in
if let theme = response {
Api.logo = theme["logo"].stringValue
Constants.passwordRegx = theme["passwordRegex"].stringValue
self.performSegue(withIdentifier: Segue.login, sender: indexPath.row)
}
})
}


/// UITableview cell populating tenant informations
class TenantCell: UITableViewCell {

@IBOutlet weak var tenantImage: UIImageView!
@IBOutlet weak var tenantNameLabel: UILabel!
@IBOutlet weak var tenantUrlLabel: UILabel!

func populate(with tenant: Tenant) {
tenantNameLabel?.text = tenant.name
tenantUrlLabel?.text = tenant.url
tenantImage.image = UIImage(named: "breifcase")
}
}


Expected output










share|improve this question
















My tableview is having Disclosure indicator as an accessory item. The didSelectItem() call of this tableview cell performs an api call on background. So the view will need to wait until the response to show next page. I have to provide an activity indicator to the position of disclosure indicator. how it is possible like in ios settings page



func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Returns the cell value for each index
let cell = tableView.dequeueReusableCell(withIdentifier: TenantCell.identifier, for: indexPath) as! TenantCell
cell.populate(with: tenantList[indexPath.row])
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Api.domain = tenantList[indexPath.row].url!
sharedAFManager.getJsonData(api: Api.theme, completionHandler: { (response, statusCode) in
if let theme = response {
Api.logo = theme["logo"].stringValue
Constants.passwordRegx = theme["passwordRegex"].stringValue
self.performSegue(withIdentifier: Segue.login, sender: indexPath.row)
}
})
}


/// UITableview cell populating tenant informations
class TenantCell: UITableViewCell {

@IBOutlet weak var tenantImage: UIImageView!
@IBOutlet weak var tenantNameLabel: UILabel!
@IBOutlet weak var tenantUrlLabel: UILabel!

func populate(with tenant: Tenant) {
tenantNameLabel?.text = tenant.name
tenantUrlLabel?.text = tenant.url
tenantImage.image = UIImage(named: "breifcase")
}
}


Expected output







swift uitableview uiactivityindicatorview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 16 at 10:05









d.felber

2,87011025




2,87011025










asked Jan 1 at 6:01









Vaisakh KPVaisakh KP

302317




302317













  • where is cellForRowAt method code? plz upload your full code

    – Pratik Prajapati
    Jan 1 at 6:40











  • Added cellForRowAt method to the code sample

    – Vaisakh KP
    Jan 1 at 6:50



















  • where is cellForRowAt method code? plz upload your full code

    – Pratik Prajapati
    Jan 1 at 6:40











  • Added cellForRowAt method to the code sample

    – Vaisakh KP
    Jan 1 at 6:50

















where is cellForRowAt method code? plz upload your full code

– Pratik Prajapati
Jan 1 at 6:40





where is cellForRowAt method code? plz upload your full code

– Pratik Prajapati
Jan 1 at 6:40













Added cellForRowAt method to the code sample

– Vaisakh KP
Jan 1 at 6:50





Added cellForRowAt method to the code sample

– Vaisakh KP
Jan 1 at 6:50












3 Answers
3






active

oldest

votes


















1














Please write in cellForRowAt Method :



cell.accessoryType = .disclosureIndicator


Then in didSelectRowAt Method please write



guard let cell : TenantCell = (tableView.cellForRow(at: indexPath) as! TenantCell) else {
return
}
cell.accessoryView = activityIndi
activityIndi. startAnimating()


After geting the response



activityIndi. stopAnimating()


It may helps you. Thank you






share|improve this answer
























  • Please press the up button for vote my answer. Thank you

    – Sanjukta
    Jan 18 at 9:57



















2














Add Activity Indicator in TableViewCell As per your required



   class TenantCell: UITableViewCell {

@IBOutlet weak var tenantImage: UIImageView!
@IBOutlet weak var tenantNameLabel: UILabel!
@IBOutlet weak var tenantUrlLabel: UILabel!
@IBOutlet weak var activityIndi: UIActivityIndicatorView!

func populate(with tenant: Tenant) {
tenantNameLabel?.text = tenant.name
tenantUrlLabel?.text = tenant.url
tenantImage.image = UIImage(named: "breifcase")
if tenant.isLoaderShow{
activityIndi.startAnimating()
}else{
activityIndi.stopAnimating()
}


Add one Bool Variable to your Tenant Model isLoaderShow and Change as per api completion and reload the tableView or reload tableViewCell






share|improve this answer


























  • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading like in my referral image

    – Vaisakh KP
    Jan 1 at 8:17













  • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading.

    – Vaisakh KP
    Jan 1 at 8:17






  • 1





    Yes, you can achieve this using Hide and Show Disclosure indicator as per api completion

    – Kaushik Makwana
    Jan 1 at 8:21



















1















  • Place right Arrow image and activity indicator in your tableviewCell first. (Default
    right_Arrow_image.isHidden = false and indicator.isHidden = true )


  • in didSelectRowAt method hide right_Arrow_image.isHidden = true and indicator.isHidden = false


  • Then call your webservice and after getting response Again set it as first step and move to the next screen







share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993340%2fdisplaying-activity-indicator-to-the-right-of-tableview-row%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Please write in cellForRowAt Method :



    cell.accessoryType = .disclosureIndicator


    Then in didSelectRowAt Method please write



    guard let cell : TenantCell = (tableView.cellForRow(at: indexPath) as! TenantCell) else {
    return
    }
    cell.accessoryView = activityIndi
    activityIndi. startAnimating()


    After geting the response



    activityIndi. stopAnimating()


    It may helps you. Thank you






    share|improve this answer
























    • Please press the up button for vote my answer. Thank you

      – Sanjukta
      Jan 18 at 9:57
















    1














    Please write in cellForRowAt Method :



    cell.accessoryType = .disclosureIndicator


    Then in didSelectRowAt Method please write



    guard let cell : TenantCell = (tableView.cellForRow(at: indexPath) as! TenantCell) else {
    return
    }
    cell.accessoryView = activityIndi
    activityIndi. startAnimating()


    After geting the response



    activityIndi. stopAnimating()


    It may helps you. Thank you






    share|improve this answer
























    • Please press the up button for vote my answer. Thank you

      – Sanjukta
      Jan 18 at 9:57














    1












    1








    1







    Please write in cellForRowAt Method :



    cell.accessoryType = .disclosureIndicator


    Then in didSelectRowAt Method please write



    guard let cell : TenantCell = (tableView.cellForRow(at: indexPath) as! TenantCell) else {
    return
    }
    cell.accessoryView = activityIndi
    activityIndi. startAnimating()


    After geting the response



    activityIndi. stopAnimating()


    It may helps you. Thank you






    share|improve this answer













    Please write in cellForRowAt Method :



    cell.accessoryType = .disclosureIndicator


    Then in didSelectRowAt Method please write



    guard let cell : TenantCell = (tableView.cellForRow(at: indexPath) as! TenantCell) else {
    return
    }
    cell.accessoryView = activityIndi
    activityIndi. startAnimating()


    After geting the response



    activityIndi. stopAnimating()


    It may helps you. Thank you







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 7 at 10:11









    SanjuktaSanjukta

    900315




    900315













    • Please press the up button for vote my answer. Thank you

      – Sanjukta
      Jan 18 at 9:57



















    • Please press the up button for vote my answer. Thank you

      – Sanjukta
      Jan 18 at 9:57

















    Please press the up button for vote my answer. Thank you

    – Sanjukta
    Jan 18 at 9:57





    Please press the up button for vote my answer. Thank you

    – Sanjukta
    Jan 18 at 9:57













    2














    Add Activity Indicator in TableViewCell As per your required



       class TenantCell: UITableViewCell {

    @IBOutlet weak var tenantImage: UIImageView!
    @IBOutlet weak var tenantNameLabel: UILabel!
    @IBOutlet weak var tenantUrlLabel: UILabel!
    @IBOutlet weak var activityIndi: UIActivityIndicatorView!

    func populate(with tenant: Tenant) {
    tenantNameLabel?.text = tenant.name
    tenantUrlLabel?.text = tenant.url
    tenantImage.image = UIImage(named: "breifcase")
    if tenant.isLoaderShow{
    activityIndi.startAnimating()
    }else{
    activityIndi.stopAnimating()
    }


    Add one Bool Variable to your Tenant Model isLoaderShow and Change as per api completion and reload the tableView or reload tableViewCell






    share|improve this answer


























    • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading like in my referral image

      – Vaisakh KP
      Jan 1 at 8:17













    • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading.

      – Vaisakh KP
      Jan 1 at 8:17






    • 1





      Yes, you can achieve this using Hide and Show Disclosure indicator as per api completion

      – Kaushik Makwana
      Jan 1 at 8:21
















    2














    Add Activity Indicator in TableViewCell As per your required



       class TenantCell: UITableViewCell {

    @IBOutlet weak var tenantImage: UIImageView!
    @IBOutlet weak var tenantNameLabel: UILabel!
    @IBOutlet weak var tenantUrlLabel: UILabel!
    @IBOutlet weak var activityIndi: UIActivityIndicatorView!

    func populate(with tenant: Tenant) {
    tenantNameLabel?.text = tenant.name
    tenantUrlLabel?.text = tenant.url
    tenantImage.image = UIImage(named: "breifcase")
    if tenant.isLoaderShow{
    activityIndi.startAnimating()
    }else{
    activityIndi.stopAnimating()
    }


    Add one Bool Variable to your Tenant Model isLoaderShow and Change as per api completion and reload the tableView or reload tableViewCell






    share|improve this answer


























    • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading like in my referral image

      – Vaisakh KP
      Jan 1 at 8:17













    • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading.

      – Vaisakh KP
      Jan 1 at 8:17






    • 1





      Yes, you can achieve this using Hide and Show Disclosure indicator as per api completion

      – Kaushik Makwana
      Jan 1 at 8:21














    2












    2








    2







    Add Activity Indicator in TableViewCell As per your required



       class TenantCell: UITableViewCell {

    @IBOutlet weak var tenantImage: UIImageView!
    @IBOutlet weak var tenantNameLabel: UILabel!
    @IBOutlet weak var tenantUrlLabel: UILabel!
    @IBOutlet weak var activityIndi: UIActivityIndicatorView!

    func populate(with tenant: Tenant) {
    tenantNameLabel?.text = tenant.name
    tenantUrlLabel?.text = tenant.url
    tenantImage.image = UIImage(named: "breifcase")
    if tenant.isLoaderShow{
    activityIndi.startAnimating()
    }else{
    activityIndi.stopAnimating()
    }


    Add one Bool Variable to your Tenant Model isLoaderShow and Change as per api completion and reload the tableView or reload tableViewCell






    share|improve this answer















    Add Activity Indicator in TableViewCell As per your required



       class TenantCell: UITableViewCell {

    @IBOutlet weak var tenantImage: UIImageView!
    @IBOutlet weak var tenantNameLabel: UILabel!
    @IBOutlet weak var tenantUrlLabel: UILabel!
    @IBOutlet weak var activityIndi: UIActivityIndicatorView!

    func populate(with tenant: Tenant) {
    tenantNameLabel?.text = tenant.name
    tenantUrlLabel?.text = tenant.url
    tenantImage.image = UIImage(named: "breifcase")
    if tenant.isLoaderShow{
    activityIndi.startAnimating()
    }else{
    activityIndi.stopAnimating()
    }


    Add one Bool Variable to your Tenant Model isLoaderShow and Change as per api completion and reload the tableView or reload tableViewCell







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 1 at 7:29

























    answered Jan 1 at 7:21









    Kaushik MakwanaKaushik Makwana

    854422




    854422













    • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading like in my referral image

      – Vaisakh KP
      Jan 1 at 8:17













    • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading.

      – Vaisakh KP
      Jan 1 at 8:17






    • 1





      Yes, you can achieve this using Hide and Show Disclosure indicator as per api completion

      – Kaushik Makwana
      Jan 1 at 8:21



















    • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading like in my referral image

      – Vaisakh KP
      Jan 1 at 8:17













    • Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading.

      – Vaisakh KP
      Jan 1 at 8:17






    • 1





      Yes, you can achieve this using Hide and Show Disclosure indicator as per api completion

      – Kaushik Makwana
      Jan 1 at 8:21

















    Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading like in my referral image

    – Vaisakh KP
    Jan 1 at 8:17







    Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading like in my referral image

    – Vaisakh KP
    Jan 1 at 8:17















    Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading.

    – Vaisakh KP
    Jan 1 at 8:17





    Sorry this doesn't full-fill my requirement. as i need to show the activity indicator in place of Disclosure indicator on loading.

    – Vaisakh KP
    Jan 1 at 8:17




    1




    1





    Yes, you can achieve this using Hide and Show Disclosure indicator as per api completion

    – Kaushik Makwana
    Jan 1 at 8:21





    Yes, you can achieve this using Hide and Show Disclosure indicator as per api completion

    – Kaushik Makwana
    Jan 1 at 8:21











    1















    • Place right Arrow image and activity indicator in your tableviewCell first. (Default
      right_Arrow_image.isHidden = false and indicator.isHidden = true )


    • in didSelectRowAt method hide right_Arrow_image.isHidden = true and indicator.isHidden = false


    • Then call your webservice and after getting response Again set it as first step and move to the next screen







    share|improve this answer






























      1















      • Place right Arrow image and activity indicator in your tableviewCell first. (Default
        right_Arrow_image.isHidden = false and indicator.isHidden = true )


      • in didSelectRowAt method hide right_Arrow_image.isHidden = true and indicator.isHidden = false


      • Then call your webservice and after getting response Again set it as first step and move to the next screen







      share|improve this answer




























        1












        1








        1








        • Place right Arrow image and activity indicator in your tableviewCell first. (Default
          right_Arrow_image.isHidden = false and indicator.isHidden = true )


        • in didSelectRowAt method hide right_Arrow_image.isHidden = true and indicator.isHidden = false


        • Then call your webservice and after getting response Again set it as first step and move to the next screen







        share|improve this answer
















        • Place right Arrow image and activity indicator in your tableviewCell first. (Default
          right_Arrow_image.isHidden = false and indicator.isHidden = true )


        • in didSelectRowAt method hide right_Arrow_image.isHidden = true and indicator.isHidden = false


        • Then call your webservice and after getting response Again set it as first step and move to the next screen








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 18 at 7:41









        Kaushik Makwana

        854422




        854422










        answered Jan 1 at 9:02









        PunitPunit

        829310




        829310






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993340%2fdisplaying-activity-indicator-to-the-right-of-tableview-row%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules