Segmented Control to change views - iphone

I have created an up/down arrow segmented control button on the right side of the navigation bar in my detail view. In a table based application, how can I use these up/down arrows to move through cells in the parent table?
The apple "NavBar" sample code has an example of this but the controls are not functional.
The iBird program has this functionality as well and it is very nice. Download the "iBird 15" program for free.
Any thoughts?
Thanks!

Set the segmented control to momentary mode, and set the control's action for UIControlEventValueChanged to point to your view controller. Then your view controller can change the selection in the table, or whatever it is you're doing with tables. (I'm not sure if you're using a UITableView or something else.)

Related

Using UIPage Control

I have been trying to build a app where you touch three different buttons and then go to there new view. Its it possible to use a UIPage Control? If so How would you go about doing that. For example I have three views. Apple, Orange, Cherry. I would like the user to flick between these three views. I need them to be three separate views i can't just have the image change.
How would I go about using the UIPage Control and switching views?
UIPageControl doesn't deal with switching views itself, it just provides the dots that are typically displayed at the bottom of a paged view and it can be tapped to go one page forward or backward (instead of swiping the actual view). The actual view that displays the content is typically a UIScrollView with pagingEnabled set to YES.
When the control is tapped, it sends the UIControlEventValueChanged event to its target. You'll then have to scroll the UIScrollView to the right page yourself.

How to make all the segments of the UISegmentedControl selected on the click of a button?

I have an application in which I have a segmented control with seven segments in it. I have a button nearby to my segmented control. I want that when I click on my button all my segments of the segmented control should remain selected.
I think this is not possible as it is segmented control. You can create custom buttons and add images as background image to buttons and handle same. This can make you work easy.
A UISegmentedControl isn't meant to work like that, ie to have multiple selections.
It might be possible to override it, but I would recommend instead creating your own custom control, or perhaps create an array of Buttons or Switches.

Scrolling through UIScrollView in Interface Builder for Xcode 4

This seems to me as though it would be a common problem, but I can't seem to find the answer anywhere. This question seems to address the issue, but I can't seem to get the solution to work and I'm not sure it's referring to Xcode 4.
When using Interface Builder in Xcode 4 and working with a UIScrollView, is there a way to scroll the view down in Interface Builder itself to view/add/edit controls that are out of the viewable section of the screen? I've managed to push a couple controls down using the arrow keys, but now I can't see them and therefore can't manipulate them in Interface Builder. Scrolling the view in IB would be first prize, but if there's a way to even select the controls using a drop-down menu or whatever so I can push them back up with the arrow keys, that would at least be something. Thanks.
Set the ViewController's Simulated Size to Freeform and set a very large height. E.g: 1000 and voilĂ ! You can now scroll to see all the stuff and add even more! :)
P.S: Remember to set set Fixed when you are finish to avoid problems!
Just a workaround which helps in Xcode4:
Expand the Objects Panel which resides on the left of the Interface Builder view (there is the tiny arrow at the bottom of the panel).
Drag your UIScrollView from the view hierachy and place it on the top level.
Now you can resize it to access more content (scrolling to that content did not work for me).
When you are done adding child views to the scrollview, you need to resize it back to be smaller or the same size as the parent view.
After your changes you would need to put back the scroll view where it belongs in your hierachy
I typically do the following when I want to (have to) build a long scrolling screen:
Set the size of the View Controller to Freeform
Set the height of the top level View to something very large
Arrange all the controls that I want on the View
Select all the controls
Select Editor->Embed In->Scroll View
Set the size of the View Controller back to normal (typically Inferred)
Well, there are a few different things you can do. There is a list of items in your view you can open on the left of the workspace by clicking the button that looks like a little play button on the toolbar. Double clicking any item selects it so you can use the arrow keys.
The best option is to use the layout panel (typically on the right) and enter position values manualy. Sometimes I will use this to move my scrollview up to where I can see where I'm working then move it back.
I found a solution although you have to use a Table view controller. If you define the table as static, the scroll works in interface builder when the table is bigger than the windows size. Moreover, a standard view can be added to the top and bottom of the table, these views are scrollable as well. The scroll is made once the controller is selected. I hope you find this trick useful.
I know this isn't exactly what you were looking for, but I always just drag the scroll view out of the view controller onto the "pasteboard" where you can resize it at will and see the whole thing.
Once I make my edits I simply resize it to fit it's allotted space in my view and place it back in the view controller.
set the root view to freeform and ~1000 pt height, go through the child views and set them to this height as well(including scroll view), in the viewdidload method set the height to the appropriate size.

icon selector using two view

Need help with the following. I am creating two different combinations of view/controllers that allow me to add/edit a set of information , think tasks or some type of to-do. I have all the data capture/store functionality working.
I decided that it would be nice to have an icon associated to these tasks. So the icon would show up in the UITableview. I commissioned 18 customer 44x44 icons that would be added tot he table.
But there is where I'm stuck:
I was to add/edit views to have the capability to select an icon to attach to the tasks. In order to do so, i added a 44x44 round-rect button with one of the images as a default. I wanted to have that button trigger another view with the 18 icons so the user selects one and it passes control back to the main view and updates de selected icon appropriately.
I created this little 18 icon view together with the main view, which is based on a scroll view. I configured the little icon view to be hidden.
But I have no idea if the little view should be a subview of the main view, who should be the file owner, how do I make it appear hidden as the main view is displayed and toggle t as needed...
I am stumped. Anyone done something like this? Ideas? Things I completely messing up, you can think of?
Thanks in advance
Probably the easiest way to hide and show the view is to adjust the "alpha" property on the view. If you set the alpha of the little view to 0 it will be hidden, and when you set it to 1 it will be showing. So in your awakeFromNib function (or wherever you are doing initialization) you can add the littleView and set the alpha to 0 so it starts hidden. I suggest adding the littleview to your mainview unless for some reason the little view will have any part of it outside of the mainview. Then, when the user selects the icon to change it, you can set the alpha to 1. Finally, when the user chooses from the view, you would set the alpha back to 0.
Note:
This is not the most efficient use of memory because the view is technically always around. So if you think that you will be low on memory I would suggest creating the view programmatically when needed and removing it from mainview when the user is done. (But only do this if you think it will be an uncommon task because creating the view with a bunch of images will probably be a relatively expensive operation).

iPhone SDK allow touches to affect multiple views

I have a main view that has has two buttons on it that control methods to display the next image and display the previous image. In this case the 'Image' is a class that inherits from UIImageView and has multiple pictures on it that you can interact with, and I call this class a 'Pane'. The pane itself handles all the user interaction itself while the main view controls the display of next and previous panes with the buttons. Here is my dilemma, because the pane fully covers the main view it wont allow for the user to tap the buttons on the main view! So once a pane pops up you cannot change it via the buttons! Is there a way to allow touches through transparent parts of a view, or if not how in the world do I achieve this?!
I cannot pass touchesBegan or any of those methods from the pane to the superview because all of the button touch methods are created in the xib file.
I cannot insert the pane under the control panel because then you wouldn't be able to interact with the pane. And as far as I know theres no way to pass touch events to every single pane within the paneHoldingArray that belongs to the main view
I cannot add the command buttons inside of the pane because I want to be able to replace the command button's image with a thumbprint render of the next/previous pane.
I've been stuck on this for a very long time, please somebody help me out with a fix action or a new way to re-engineer the code so that it will work!
If you want the buttons to capture events, then layer them above the pane. You say you cannot put the control panel above the pane, so break the buttons out into another view that you can put above the pane. If you want the buttons to appear under other views, then make some completely transparent custom buttons to handle you actions that you can layer on top.
I don't know what you mean by the button touch methods are created in the xib file, but in general you cannot effectively pass touch events around. You must organize the view hierarchy so that the views you want to receive events are logically on top. However, nothing says that the views on top have to be opaque or even visible.