iphone - how to refresh a uiview with a scrollview? - ios4

any advice welcome! :)
My screen design is landscape with text on the left (this is in the main view) and a scrollview on the right (which contains an interactive map image)
The mainviewcontroller contains the scrollview as an outlet.
In the scrollviewcontroller I add a 'map' view into the scrollview.
In the mapviewcontroller I update an array in the appdelegate, depending on the user input.
I would now like to refresh the main uiview that contains the scrollview to display the updated text from the appdel array - whenever the user clicks a button.

You should call your view's -(void)setNeedsDisplay method to cause it to redraw.
[myView setNeedsDisplay];
See Apple's reference documentation here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html%23//apple_ref/doc/uid/TP40006816-CH3-BBCCADHC

You have to call viewWillAppear from the other viewcontroller

Related

Why no back button on DateElement picker?

This walkthrough for MT.D shows a back button on the UIDatePicker that appears when a DateElement is tapped. I'm in an iPad app, and using an MT.D DialogViewController as a subview in an overall UIView. When the date picker slides up I just get the black background with no way to dismiss the picker (no nav bar w/ back button). Same problem exists for the radio group picker. Is this because the dialog view controller is being used as a subview? Any ideas how I might get a nav bar up with a back button using the built-in picker logic?
You must use the DialogViewController as a child element of a UINavigationController to get the back button. On iPad, you can embed the UINavigationController in a UIPopoverController.
Adding the view of a controller into the view of another controller is not considered good design on iOS and won't result in the behavior you expect.

I want a different title to appear in the navigation bar for each imageview in my scroll view (xcode 4.2, iOS 5.0)

I have a scroll view, and when a user moves from one imageview to the next, I want the title in the navigation bar to change. So I want to set a new title for the navigation bar for each image in the scroll view. How would I go about doing this?
Thank you very much for your help.
Write a delegate for your scroll view. In the delegate, implement the scrollViewDidScroll: method to figure out which image is currently visible and change the title.
To eliminate your incompatible type warning, you can declare that ScrollViewController adopts the UIScrollViewDelegate protocol:
#interface ScrollViewController : UIViewController <UIScrollViewDelegate>

iPad: Correct approach to custom navigation items in UINavigationController

This relates to a question I asked a few days ago: iOS: Setting text in nib subview from view in UITabBar/UINavigationController application
I need to put the search bar and buttons on the top right of a navigation controller, this is more than the standard single button that UINavigationController.navigationItem.rightBarButtonItem allows so I am using the initWithCustomView: method of UIBarButtonItem to load a view from a nib file.
In my particular case, i've put the view as a seperate item in the main view file for that form
The problem i've got is load and display sequence and I wanted to know if this was the right approach to this?
It seems that the following happens:
viewDidLoad on my main window gets called
viewDidAppear on my main window gets called and I set up rightBarButtonItem
I then want to populate a text field on that search bar but because the loading of the view for the button item happens in the main thread, I don't know when it's appeared.
Would I be better to create a new class with nib for the search bar and buttons which would then have a viewDidLoad/viewDidAppear and I could then create a delegate function so I could 'deQueue' the text to go into the search bar?
Or, am I missing something really simple?

Monotouch: insert an UISegmentedControl into UIPopoverController header

I would insert a UISegmentedControl into UIPopoverController header. How can I do?
Check this link.
UISegmentedControl embedded in a UINavigationBar/Item.
I would replicate a similar behavior.
Thank you!!
EDIT: In particular, the UISegmentedControl is composed by three segments. Each segment displays a different views inside the UiPopoverController.
The answer is in the link you posted yourself. Embed your view controller in a navigation controller and add the segmented control as the title view of your navigation item. The popover controller is smart enough to recognize this and will draw your navigation bar as part of its own header.

ScrollView with paging iphone sdk

in the main view controller i have a scrollview and paging control.
i have added another viewcontroller's view as a page of paging control in scrollview.
now i have 9 buttons on that view controller's view which is inside scroll view.
now when i click on the buton i wants that main view controller's view should be pushed to another view controller.
but not getting how it can be done as the buttons are in view which is in the scrollview.
When a user interface element created in interface builder seems not to be doing what you told it to do, you should verify that:
you saved your changes to the nib in IB
that you correctly declared your ivars/properties as IBOutlet and connected your outlets in IB
that there are no views hijacking your events.
If the buttons in your view inside the scroll view don't appear to be getting press events, you may need to adjust the userInteractionEnabled property of parent views.
You can "move" any view from one view hierarchy to another by doing:
[myView removeFromSuperview];
[anotherParentView addSubview:myView];

Resources