pushViewControllerAnimated pushes ViewController over whole screen - iphone

I am trying to show a modal view controller that hovers over another viewcontroller. Now the problem is when I use pushViewControllerAnimated the view controller that gets pushed will be as big as the whole iphone screen. I just want it to be half size of the screen.
How to adjust the size?

What exactly do you mean by half size of the screen?
If you are interested in the Facebook-like side menu, have a look at:
https://github.com/Inferis/ViewDeck
or https://github.com/BenHall/ios_facebook_style_navigation
If you are interested in an alertview-like small modal view controller, you might:
Consider using an alert view and adding some subviews
Read http://devblog.bu.mp/easy-partial-screen-modals-on-ios if you really have to use an UIViewController for that, which is not recommended by Apple (http://blog.carbonfive.com/2011/03/09/abusing-uiviewcontrollers/)
Hope this helps.

Related

Load a view controller created inside a storyboard as a subview (into a part of the screen) of another view controller

I am currently developing as app for iPad. And I need to create a tabbar. The problem is that, for design purposes, I need the tabbar to be on the top half of the screen and not on the bottom as it is on the default tabbar controller.
Once the tabbar is on top I want that when a button is touched, the subview bellow the tab is changed. Furthermore, the subview that should be loaded was alson designed inside the storyboard. The following sketch shows what I want it to look like:
On my research I found a solution (here) for putting the tabbar on top. Now my problem is on loading a subview bellow it.
I tried it with [self.view addsubview:theNameOfTheViewCreatedINStoryboad.view] but the application simply hangs when I press the button.
I think that is because I am not specifying anywhere what should be the dimension of the new view or where on the scree should it be placed. The reason for that is because I do not know where it should be done.
Can anyone give me some lights on this matter? Is the referred approach the best one for putting a tabbar on top? How can I solve the subview problem?
Glad to see you are using a toolBar and not a tabBar. Even better would be to create a custom content view controller.
You should be looking into using containment:
UIViewController containment
How does View Controller Containment work in iOS 5?
positioning UIViewController containment children
check out the docs

Webview and another View within UIView

So I have a UIViewController, and within that I have two views, a WebView and another view that I made (taken from this tutorial: http://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view).
In the nib file, I have the rate view on the bottom; but when I run the simulator and go to that view, I don't want the rate view to be on the bottom ALL the time; only when I am at the bottom of the WebView.
(Sorry for not being more clear, basically the Rate View would be like a part of the WebView on the bottom, and the user would see it if they scroll to the bottom of WebView).
probably not an answer, but the easiest thing would be to incorporate that second view into the content of the web view page. If that's not possible, you could try putting the 5 star view and web view inside of a UIScrollView, but it may cause problems with event handling. Another possibility would be to try to detect when the web view scrolling reaches the bottom and then pop up the 5 star view from the bottom (from off-screen). I think that can be done since UIWebView conforms to UIScrollViewDelegate.

iPhone, how what I show smaller views ontop of normal view and switch between my current normal views?

I'd like to display some small tutorial dialogs on top of my exiting views. I want to be able to see my existing views behind these smaller views.
Do I have to use view controllers in the same I way I would me normal views, and presentmodalviewcontroller etc ?
I haven't tried making a smaller view in interface builder before.
Also, say I want to move to another one of my existing views, full screen, while in my tutorial view. How would I close my tutorial view move to the next full screen view and launch another tutorial view ?
Example code or pseudo code would be welcome.
If your tutorial dialogs are just text, you could use UIAlertView to show the information to the user, so they can just read it and click the OK button when they're done. It's a very easy way to show some text to the user.
If you need to include images or other interactive items in your tutorial dialogs, the easiest way might be for you to just have your fullscreen view's view controller create a new view and put it up. So in this case, you'd create your view in Interface Builder, and when you want to show it, instantiate it using -[UIBundle loadNibNamed:owner:options:] and add it as a subview of your main view. Of course, it may even be easier to create the tutorial view programmatically from your view controller rather than using a nib for them at all.
Regarding the question of moving on to another fullscreen view, you would probably want to look into embedding your view controllers in a UINavigationController. This would allow you to push from the first controller to the second very easily, and the user would be able to just tap the Back button to get back to the first. If you're not looking for a navigation bar type of interface, you could present the second view controller as a modal view controller by calling -[UIViewController presentModalViewController:animated:] on your main view controller. This will pop up the second view controller fullscreen, and the user can dismiss it when they're done. Check out Apple's great documentation on UINavigationController to get a feel for how to use that:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/NavigationControllers/NavigationControllers.html%23//apple_ref/doc/uid/TP40007457-CH103-SW1
I would think that you could use existing UIViewController and simply add a new UIView that is of desired dimensions, that sits in front of other views and which is non-opaque and has alpha less than 1.
If you want a general purpose tutorial mechanism that can be placed atop any one of many UIViewControllers, then you would want to extract the navigation logic, etc.
Sorry, no code - just a few quick thoughts.

Current UIView Questions iPhone SDK

I posted earlier but am running into similar problems again. Basically the way that my app is setup there is a top bar that is basically just a static image that has UIButtons placed on top of it. That is the Main View Controller and is persistent no matter what view is shown beneath it. I can't use a navigation controller because it is not possible to change the height and I need the bar to be significantly larger than a navbar. However my bar is functioning in much the same way. There is a "Home" Button, a "Back" Button and several destination buttons.
I understand how to switch views from say the home screen. My confusion comes with the back button. In order to press back the app is going to need to know what view is currently being displayed so that it can be removed from view and a new subview can be added. Ideally I would use the UINavigationController so that I can push and pop views which is really what I want to do here, however that is not possible because of the visual problem.
Does anybody know of a method that returns the current displayed view so I could do something like the following
[currentview.view removeFromSuperView];
[self.view insertSubview:experienceViewController.view atIndex:0]
You can use UINavigationController with the nav bar hidden. Put the nav controller inside a view that does have your jumbo toolbar and you'll have access to the push/pop behavior you're looking for.

How to present a modal view controller with fixed UIToolbar?

I am trying to set up a Modal View Controller, that that lies below a fixed toolbar. therefore the toolbar is supposed to stay on top while the modal view rolls in.
the Safari-App does that for example, when hitting the bookmarks-button. the toolbar stays, the buttons change..
I tried a couple of things like pushing the toolbar to the front and ended up not using the presentModalViewController method at all, and animating the new View manually into a subview instead. but that brought a couple of other issues along.
I'm not sure what you are saying, when you press add bookmark in safari, a new modal view shows with no tool bar. The navigation bar at the top is not a tool bar if that is what you mean. They are UIToolbarItem set into self.navigationItem.
All modal views I've seen are animated until they take up the whole of the screen. Those modal-like views that only scroll up to a certain point in some apps, are done by hand. Maybe you can cover those issues encountered when doing this by hand in another post?