subinspathilettu / SJSegmentedViewController

MIT License
334 stars 126 forks source link

View controller not reloading ! #40

Closed Karthikeyan1108 closed 7 years ago

Karthikeyan1108 commented 7 years ago

My requirement is like I have to add categories dynamically from API . Using single view controller as an instance am creating the segment controllers . Stuck with loading API based on category Id as the view will appear or view did load method is not getting called on view controller. Kindly guide me to solve this issue please. Urgent.

SonnetXavier commented 7 years ago

Hi @Karthikeyan1108 ,

One of the solution is to use our delegate method didMoveToPage , you can invoke the method calling your API in your View Controller from this delegate method. Please refer the code snippet:

func didMoveToPage(_ controller: UIViewController, segment: SJSegmentTab?, index: Int) { if segmentController.segments.count > 0 {

        if controller is TestimonialTableViewController{
            print(" TestimonialTableViewController")
              let viewController : TestimonialTableViewController = controller as! TestimonialTableViewController
            viewController.callAPI()
        }
       print("Selected tab")
    }
}
Karthikeyan1108 commented 7 years ago

Thank you for your reply.It worked.The segments label are auto populating its size. Example: Firstviewcontroller title is "Home" Secondviewcontroller title is "Live" Thirdviewcontroller title is "Current affairs"

Now am able to see lot of gaps between the titles in the segment bar. is that empty space be reduced ?

SonnetXavier commented 7 years ago

Could you share a screenshot of this particular screen .

Karthikeyan1108 commented 7 years ago

Kindly Look in to the Screenshot.

screen shot 2017-03-09 at 12 26 37 pm

subinspathilettu commented 7 years ago

@Karthikeyan1108 We are giving equal width for all title tabs. So that you see gap between adjacent tabs.

Karthikeyan1108 commented 7 years ago

Is there any possible way to reduce the height so that it fits according to the text length ?

On Fri, 17 Mar 2017 at 7:55 AM, Subins P Jose notifications@github.com wrote:

@Karthikeyan1108 https://github.com/Karthikeyan1108 We are giving equal width for all title tabs. So that you see gap between adjacent tabs.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/subinspathilettu/SJSegmentedViewController/issues/40#issuecomment-287249299, or mute the thread https://github.com/notifications/unsubscribe-auth/APf2fFSYnG1HSG0iiSc87iQf7xu1EdEJks5rme7-gaJpZM4L1df4 .

-- Thanks Regards,

Karthikeyan.P

feliciaf commented 7 years ago

how was you able to show the view controllers? i am unable to..

Karthikeyan1108 commented 7 years ago

Hi @feliciaf
I didn't understand your question.Could you please mention in detail?