Avoiding from MomoryLeak while performing Segues - memory-leaks

I can use navigation without segues (1) but I would like to use it (2).
Performing a segue and navigating back make my app slower ! Because it doesn't dispose destination view when I navigate back. How do you use this segues in a right way ?
/*1) This code ok! But what about segues */
if(_tabbarController==null)
_tabbarController = (UITabBarController)this.Storyboard
.InstantiateViewController ("MainTabbarController");
this.NavigationController.PushViewController (_tabbarController,true);
/*2) If I run this code I get a new instance of UITabbar */
this.PerformSegue("SegueShowDetail",this);

If you're using the Storyboard and a Navigation Controller, the navigation controller should automatically release your view and associated memory with it when it pops off the stack.
For example, if you've got a method that gets called when you push a button to go to another view, you'd have:
[self performSegueWithIdentifier:#"mySegueName" sender:self];
When you click the back button at the top left of your secondary view, this will trigger the navigation controller to dispose of the view.

Related

Update parent in UINavigationController from SubView

Forgive me if this has been asked/answered already but I couldn't find it anywhere (at least no in Monotouch - vaguely answer for ObjC. So completely new to Monotouch but I have everything completed in my application that I want with one exception. I'm trying to update a parent of a subview.
Here is the scenario:
I have a UINavigationController with a UIView (not a table) which has a few buttons on it that directs via a PushViewController to a Subview. I make some changes on the subview, which I would like reflected back on the parent. I can of course add a manual refresh button if I wanted but was looking for something a little better.
I did see some things that referred to using a viewWillAppear but couldn't find any good examples. My attempts failed pretty bad, so any suggestions would be great.
Thanks,
Richard
If you have a UINavigationController, it has a "back" button on top. Once this is hit by the user (or if you pop to a previous view controller), the currently view controller shown will trigger ViewWillDisappear and ViewDidDisappear and the view below (the one with your buttons) will fire ViewWillAppear and ViewDidAppear. Just overload those and update your UI state in there.

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?

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];

How do i refresh a tableview after returning from Background

How do I refresh a tableview after returning from Background(when the user hit home button and comes back later). Its not calling the viewWillApper delegate method.
Thanks,
Shinto.
Override applicationDidBecomeActive or applicationWillEnterForeground in the appDelegate. Then I would either call the table view controller to reload or use a NSNotification.
Note: applicationDidBecomeActive is also called when the app launches. See: Understanding iOS 4 Backgrounding and Delegate Messaging
u can do it in the Home Button. First Get the ViewController thats hold the TableView and do further action...

How to add Normal viewcontroller after navigation controller in windows based application?

In my windows based applicaton, after login screen and registration page I added navigation controller for next two views. After pressing button present on second navigation window,again i want normal view controller and not navigation. But Its giving me navigation window with back button which takes me to second navigation window.
Can anyone plz tell me the solution??
You have a couple choices: you can truly eliminate the Navigation Controller entirely and replace it with another UIViewController (more complicated), or you can just push a new UIViewController that will not have a navigation bar/back button, and use that as the effective "root" view controller of your application from there on out. Without the navigation bar, your view controller will look like a "normal" view controller.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.hidden = YES;
...
}

Resources