?
Solved

How to use segue to replace only half of screen

Posted on 2012-08-27
17
Medium Priority
?
923 Views
Last Modified: 2012-09-11
Experts:

I have a segmented button at top of screen with three options.  I want to display a View in the lower portion of the screen based on the user selection.  All research shows that I need a new ViewController for each option but that would change to the new ViewController, hiding my buttons at the top of the screen.  Do I need to include my three buttons for each ViewController?  Is there not a way to just display the appropriate View in the lower portion of the screen.  I'm confused.

Thank you.
0
Comment
Question by:pdlarue
  • 10
  • 7
17 Comments
 
LVL 15

Expert Comment

by:Hamidreza Vakilian
ID: 38339677
You will first create a main viewController: on mainViewController you place a uiview on top half and one in lower half. You will add mainViewController to uiwindow of your app.
You will also create a viewController which has 3 buttons. We will load this viewController in top half uiview of mainViewController;
You will create 3 viewControllers each associate with those buttons; you will load each of these on the lower uiview of the mainViewController.
Therfore in the mainViewController the top half uiview wont change since it contains the buttons. When a button is pressed you create a new instance of one of those 3 viewControllers and you load it in the lower half uiview of mainviewcontroller.
0
 

Author Comment

by:pdlarue
ID: 38343329
Hi, Programmer-x:

First off, let me thank you for your help.

I have only worked with Storyboard UIViewControllers and UIViews thus far.  Even that was in a tutorial.  I have followed your instructions but I don't understand.  Can you create a new instance of a UIViewController such that the UIView will only display where the original UIView is located (in the lower half of the mainViewController)?

I'll increase the points to 500 if you'll help me understand how to do this.

This is what I have:

I start with a UINavigationConroller and a UIViewController with a button on it to simulate some control to open my page.

Then I created the mainViewController with 2 UIViews (one on top and one on bottom) called SegmentSection and DisplaySection and created classes for each (.m/.h).

Then I create four UIViewControllers.  One for the top called SegmentViewController with class files and three for the bottom called ActivationViewController, PreferencesViewController, and AboutViewController with their respective class files.

So I can load a UIViewController into a UIView?  I don't understand.

Thank you in advance for your help.
0
 
LVL 15

Expert Comment

by:Hamidreza Vakilian
ID: 38344557
By saying loading a UIViewController into a UIView, I mean initializing an instance of that UIViewController class and then adding it's UIView as a subview to the first UIView.

I thought if you upload your Xcode project somewhere I can help you better. Since we have to access mainViewController instance from ActivationViewController, PreferencesViewController and AboutViewController and that's a little hard to explain here.
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Author Comment

by:pdlarue
ID: 38361533
Hi, Programmer-x:

Sorry for the delay.  I have to figure out where to post the code so you can get to it.  But all I have is a UIViewController with a button on it that opens another UIViewController.  No code yet.  The UIViewController that will open contains two UIViews that are empty.  I've created a UIViewController that contains the UIView that goes into the top portion of the empty one.  If you could just show me how to shove one UIViewController into the UIView of another UIViewContrroller that would be great.  I'll double the points.  Meanwhile, I'll look for a place to post the code.  There must be somewhere.  I have Google and Yahoo but I only use them for email.  Let me check into storage capabilities.  I'll post as soon as I can.

Thank you and I hope you're enjoying you Labor Day.  Take care.
0
 

Author Comment

by:pdlarue
ID: 38361546
Oh.  Wait a minute....I found the "Attach File" option.  Duh!  

Ahhhh!  But it's not allowed.  I'll look for a place to post.

Thank you.
0
 
LVL 15

Expert Comment

by:Hamidreza Vakilian
ID: 38361670
No problem; Let me know once you uploaded your project.
0
 

Author Comment

by:pdlarue
ID: 38372231
Finally!  I've posted it on FileShare at the following link:



Password = Passw0rd   (Hint:  That is a zero)

Let me know if you have problems.

Thank you for your help.  Again, I'll double the points.  And if it turns out to be a lot of work, I'll make a new question for you to give you more points.

Thanks again.
0
 

Author Comment

by:pdlarue
ID: 38372241
I don't see the link, so here it is:

http://www.fileswap.com/index.php?FOLDERID=169855
0
 
LVL 15

Expert Comment

by:Hamidreza Vakilian
ID: 38375293
Sorry but I don't find any download button on the page. You could also attach and email the project to me. Find my email address on my profile if you want.
0
 

Author Comment

by:pdlarue
ID: 38378633
OK.  Try this one:

http://www.fileswap.com/dl/g2dsN24M9

I'll try to email also.

Thank you.
0
 

Author Comment

by:pdlarue
ID: 38378655
I posted the zip file to your website.

Have a good night.
0
 
LVL 15

Expert Comment

by:Hamidreza Vakilian
ID: 38384122
I saw your project; You cannot do this using storyboards because as far as I know, storyboards will replace each entire view with a view controller at a time and it's not able to load partial view controllers (e.g. one for the half and other for the second half)

instead you should accomplish this by creating all the things manually by code. (Design related XIBs for each view controller and then load them in code as you want)

If you want I can do that for your project (and also please consider increasing the points then)
0
 

Author Comment

by:pdlarue
ID: 38384359
Yes, please, if you could just do one then I think I can follow your logic for the others.  If I have any further questions then I'll post new question with more points.

Thank you!

:-)
0
 
LVL 15

Accepted Solution

by:
Hamidreza Vakilian earned 2000 total points
ID: 38384596
Here is your corrected project:
http://5.9.197.49/Settings.zip
0
 

Author Closing Comment

by:pdlarue
ID: 38388237
You are awsome!!!!  I haven't looked at the code yet, but you went the extra mile to open all three.  Thank you so much for your help.  AWSOME!!!!!
0
 

Author Comment

by:pdlarue
ID: 38388307
Hey, Programmer-x:

I just submitted another question:

Removing margins from RTF text in UIWebView

Answer if you know how to do that.

Thanks, again.
0
 
LVL 15

Expert Comment

by:Hamidreza Vakilian
ID: 38388631
You're welcome; I will check that asap.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

     Intro      In this article, I will show you how to parse a JSON in Swift using an open source library called SwiftyJSON (https://github.com/SwiftyJSON/SwiftyJSON). If you haven't heard of a JSON before, it stands for JavaScript Object Notation…
There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question