Segmented Control loading problem in Tab View












0















I am trying to implement a segmented control into a view controller like this picture



enter image description here



In first tab everything is ok but the second tab nothing is displayed



s://i.stack.imgur.com/wnz6Y.jpg



But I really don't know what is going on.



This is my code in switch between tabs:



@IBOutlet weak var NewsView: UIView!
@IBOutlet weak var VideoView: UIView!
@IBOutlet weak var Newspaper: UIView!

@IBAction func SwitchView(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 2{
NewsView.alpha = 1
VideoView.alpha = 0
Newspaper.alpha = 0
}else if sender.selectedSegmentIndex == 1{
VideoView.alpha = 1
NewsView.alpha = 0
Newspaper.alpha = 0
}else{
Newspaper.alpha = 1
NewsView.alpha = 0
VideoView.alpha = 0
}
}









share|improve this question

























  • Can you check that wether your views are being hidden from storyboard or not?

    – Syed Qamar Abbas
    Nov 26 '18 at 9:55











  • Can you check your view is not blank and proper getter/setting is applied for different uielements.

    – Basir Alam
    Nov 26 '18 at 11:21











  • Share your table view delegate and data source code.

    – T. Pasichnyk
    Nov 26 '18 at 12:26
















0















I am trying to implement a segmented control into a view controller like this picture



enter image description here



In first tab everything is ok but the second tab nothing is displayed



s://i.stack.imgur.com/wnz6Y.jpg



But I really don't know what is going on.



This is my code in switch between tabs:



@IBOutlet weak var NewsView: UIView!
@IBOutlet weak var VideoView: UIView!
@IBOutlet weak var Newspaper: UIView!

@IBAction func SwitchView(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 2{
NewsView.alpha = 1
VideoView.alpha = 0
Newspaper.alpha = 0
}else if sender.selectedSegmentIndex == 1{
VideoView.alpha = 1
NewsView.alpha = 0
Newspaper.alpha = 0
}else{
Newspaper.alpha = 1
NewsView.alpha = 0
VideoView.alpha = 0
}
}









share|improve this question

























  • Can you check that wether your views are being hidden from storyboard or not?

    – Syed Qamar Abbas
    Nov 26 '18 at 9:55











  • Can you check your view is not blank and proper getter/setting is applied for different uielements.

    – Basir Alam
    Nov 26 '18 at 11:21











  • Share your table view delegate and data source code.

    – T. Pasichnyk
    Nov 26 '18 at 12:26














0












0








0








I am trying to implement a segmented control into a view controller like this picture



enter image description here



In first tab everything is ok but the second tab nothing is displayed



s://i.stack.imgur.com/wnz6Y.jpg



But I really don't know what is going on.



This is my code in switch between tabs:



@IBOutlet weak var NewsView: UIView!
@IBOutlet weak var VideoView: UIView!
@IBOutlet weak var Newspaper: UIView!

@IBAction func SwitchView(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 2{
NewsView.alpha = 1
VideoView.alpha = 0
Newspaper.alpha = 0
}else if sender.selectedSegmentIndex == 1{
VideoView.alpha = 1
NewsView.alpha = 0
Newspaper.alpha = 0
}else{
Newspaper.alpha = 1
NewsView.alpha = 0
VideoView.alpha = 0
}
}









share|improve this question
















I am trying to implement a segmented control into a view controller like this picture



enter image description here



In first tab everything is ok but the second tab nothing is displayed



s://i.stack.imgur.com/wnz6Y.jpg



But I really don't know what is going on.



This is my code in switch between tabs:



@IBOutlet weak var NewsView: UIView!
@IBOutlet weak var VideoView: UIView!
@IBOutlet weak var Newspaper: UIView!

@IBAction func SwitchView(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 2{
NewsView.alpha = 1
VideoView.alpha = 0
Newspaper.alpha = 0
}else if sender.selectedSegmentIndex == 1{
VideoView.alpha = 1
NewsView.alpha = 0
Newspaper.alpha = 0
}else{
Newspaper.alpha = 1
NewsView.alpha = 0
VideoView.alpha = 0
}
}






ios swift segment






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 15:57









rmaddy

242k27316380




242k27316380










asked Nov 26 '18 at 9:43









ali fallahali fallah

353210




353210













  • Can you check that wether your views are being hidden from storyboard or not?

    – Syed Qamar Abbas
    Nov 26 '18 at 9:55











  • Can you check your view is not blank and proper getter/setting is applied for different uielements.

    – Basir Alam
    Nov 26 '18 at 11:21











  • Share your table view delegate and data source code.

    – T. Pasichnyk
    Nov 26 '18 at 12:26



















  • Can you check that wether your views are being hidden from storyboard or not?

    – Syed Qamar Abbas
    Nov 26 '18 at 9:55











  • Can you check your view is not blank and proper getter/setting is applied for different uielements.

    – Basir Alam
    Nov 26 '18 at 11:21











  • Share your table view delegate and data source code.

    – T. Pasichnyk
    Nov 26 '18 at 12:26

















Can you check that wether your views are being hidden from storyboard or not?

– Syed Qamar Abbas
Nov 26 '18 at 9:55





Can you check that wether your views are being hidden from storyboard or not?

– Syed Qamar Abbas
Nov 26 '18 at 9:55













Can you check your view is not blank and proper getter/setting is applied for different uielements.

– Basir Alam
Nov 26 '18 at 11:21





Can you check your view is not blank and proper getter/setting is applied for different uielements.

– Basir Alam
Nov 26 '18 at 11:21













Share your table view delegate and data source code.

– T. Pasichnyk
Nov 26 '18 at 12:26





Share your table view delegate and data source code.

– T. Pasichnyk
Nov 26 '18 at 12:26












1 Answer
1






active

oldest

votes


















-1















  1. UISegmentedControl.selectedSegmentIndex start with 0, so have you implemented your cases in SwitchView() according to it?


  2. Why are you changing alpha value of views, you should hide and unhide the views. If your data are displaying on tableView then change data and reload tableView then no need to add multiple views.


  3. You can debug your if-else conditions using breakpoints.







share|improve this answer
























  • Why my answer gets a downvote? please explain the reason.

    – iDev750
    Nov 26 '18 at 10:50











  • I don't see the reason to downvote this answer. The questions are reasonable. But you should have asked this questions as a comments to main post, because it is not answering anything.

    – T. Pasichnyk
    Nov 26 '18 at 12:28













  • @T.Pasichnyk Thank you for your suggestion !!

    – iDev750
    Nov 26 '18 at 12:43











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%2f53478334%2fsegmented-control-loading-problem-in-tab-view%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-1















  1. UISegmentedControl.selectedSegmentIndex start with 0, so have you implemented your cases in SwitchView() according to it?


  2. Why are you changing alpha value of views, you should hide and unhide the views. If your data are displaying on tableView then change data and reload tableView then no need to add multiple views.


  3. You can debug your if-else conditions using breakpoints.







share|improve this answer
























  • Why my answer gets a downvote? please explain the reason.

    – iDev750
    Nov 26 '18 at 10:50











  • I don't see the reason to downvote this answer. The questions are reasonable. But you should have asked this questions as a comments to main post, because it is not answering anything.

    – T. Pasichnyk
    Nov 26 '18 at 12:28













  • @T.Pasichnyk Thank you for your suggestion !!

    – iDev750
    Nov 26 '18 at 12:43
















-1















  1. UISegmentedControl.selectedSegmentIndex start with 0, so have you implemented your cases in SwitchView() according to it?


  2. Why are you changing alpha value of views, you should hide and unhide the views. If your data are displaying on tableView then change data and reload tableView then no need to add multiple views.


  3. You can debug your if-else conditions using breakpoints.







share|improve this answer
























  • Why my answer gets a downvote? please explain the reason.

    – iDev750
    Nov 26 '18 at 10:50











  • I don't see the reason to downvote this answer. The questions are reasonable. But you should have asked this questions as a comments to main post, because it is not answering anything.

    – T. Pasichnyk
    Nov 26 '18 at 12:28













  • @T.Pasichnyk Thank you for your suggestion !!

    – iDev750
    Nov 26 '18 at 12:43














-1












-1








-1








  1. UISegmentedControl.selectedSegmentIndex start with 0, so have you implemented your cases in SwitchView() according to it?


  2. Why are you changing alpha value of views, you should hide and unhide the views. If your data are displaying on tableView then change data and reload tableView then no need to add multiple views.


  3. You can debug your if-else conditions using breakpoints.







share|improve this answer














  1. UISegmentedControl.selectedSegmentIndex start with 0, so have you implemented your cases in SwitchView() according to it?


  2. Why are you changing alpha value of views, you should hide and unhide the views. If your data are displaying on tableView then change data and reload tableView then no need to add multiple views.


  3. You can debug your if-else conditions using breakpoints.








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 26 '18 at 9:52









iDev750iDev750

5981315




5981315













  • Why my answer gets a downvote? please explain the reason.

    – iDev750
    Nov 26 '18 at 10:50











  • I don't see the reason to downvote this answer. The questions are reasonable. But you should have asked this questions as a comments to main post, because it is not answering anything.

    – T. Pasichnyk
    Nov 26 '18 at 12:28













  • @T.Pasichnyk Thank you for your suggestion !!

    – iDev750
    Nov 26 '18 at 12:43



















  • Why my answer gets a downvote? please explain the reason.

    – iDev750
    Nov 26 '18 at 10:50











  • I don't see the reason to downvote this answer. The questions are reasonable. But you should have asked this questions as a comments to main post, because it is not answering anything.

    – T. Pasichnyk
    Nov 26 '18 at 12:28













  • @T.Pasichnyk Thank you for your suggestion !!

    – iDev750
    Nov 26 '18 at 12:43

















Why my answer gets a downvote? please explain the reason.

– iDev750
Nov 26 '18 at 10:50





Why my answer gets a downvote? please explain the reason.

– iDev750
Nov 26 '18 at 10:50













I don't see the reason to downvote this answer. The questions are reasonable. But you should have asked this questions as a comments to main post, because it is not answering anything.

– T. Pasichnyk
Nov 26 '18 at 12:28







I don't see the reason to downvote this answer. The questions are reasonable. But you should have asked this questions as a comments to main post, because it is not answering anything.

– T. Pasichnyk
Nov 26 '18 at 12:28















@T.Pasichnyk Thank you for your suggestion !!

– iDev750
Nov 26 '18 at 12:43





@T.Pasichnyk Thank you for your suggestion !!

– iDev750
Nov 26 '18 at 12:43




















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%2f53478334%2fsegmented-control-loading-problem-in-tab-view%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

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks