Closed leoru closed 11 years ago
What is the behaviour when you do this? Although you are using the control to organize your UINavigationControllers, the behaviour of the navigation controllers will not change as a result of being contained within the KLNoteViewContoller.
I would attempt to do it using the method call rather than the accessor. i.e. try [self.navigationItem setLeftBarButtonItem: nil animated: YES/NO];
The behaviour - nothing happens. i tried [self.navigationItem setLeftBarButtonItem: nil animated: YES/NO]; nothing happens.
The problem, that if i set action on button within view: -(void)DeleteLeftItem:(id)sender { [self updateUI]; } and press this button, leftbaritem will be removed, but when i call updateUI in noteviewcontroller delegate, nothing happens.
Have you put a breakpoint to see if the code is being executed?
On 2013-02-27, at 11:37 AM, Kirill Kunst notifications@github.com wrote:
The behaviour - nothing happens. i tried [self.navigationItem setLeftBarButtonItem: nil animated: YES/NO]; nothing happens.
The problem, that if i set action on button within view: -(void)DeleteLeftItem:(id)sender { [self updateUI]; } and press this button, leftbaritem will be removed, but when i call updateUI in noteviewcontroller delegate, nothing happens.
— Reply to this email directly or view it on GitHub.
Ofcause, the code executed, but nothing happens.
i tried set navbar title in updateUI, but I did not get
Ah I think I know what is wrong
you need to do
self.navigationController.navigationItem.leftBarButtonItem = nil;
otherwise check fi self.navigationItem is nil or not to see if you are actually referencing anything
i tried self.navigationController.navigationItem.leftBarButtonItem = nil; nothing happens.
and i check self.navigationItem is nill or not - it's not nil.
Can you try to add 3-4 viewcontrollers to klnoteviewcontroller and update title or right or left bar item when viewcontrollers go to KLControllerCardStateDefault state? Maybe i do anything wrong.
tbh this is a navigationcontroller issue not related to the control. As mentioned previously the control just organizes UIViewControllers, what you do with the UIViewControllers/UINavigationControllers is up to you. Try performing the same operation with the UINavigationController outside of the control and see if it works
Try performing the same operation with the UINavigationController outside of the control and see if it works I try to change nav item title and rightbaritem from uibutton action and everything is ok. but when i try to do this in -(void) noteViewController: (KLNoteViewController) noteViewController didUpdateControllerCard:(KLControllerCard)controllerCard toDisplayState:(KLControllerCardState) toState fromDisplayState:(KLControllerCardState) fromState {}, nothing happens,unfortunately
Try
if (toState == KLControllerCardStateDefault) { NSIndexPath path = [self indexPathForControllerCard:controllerCard]; TDListViewController viewController = (TDListViewController *)[self noteView:self viewControllerForRowAtIndexPath:path]; viewController.navigationController.navigationItem.leftBarButtonItem= nil; }
}
just throwing out ideas... :P
i tried that :) unfortunately, nothing happens
try performing [noteView reloadDataAnimated:NO]; after the change
Using a break poing check if the line :
TDListViewController viewController = (TDListViewController *)[self noteView:self viewControllerForRowAtIndexPath:path];
is actually returning a TDListViewController and not a UINavigationController
Just a note as well, in the code:
NSIndexPath path = [self indexPathForControllerCard:controllerCard]; TDListViewController viewController = (TDListViewController *)[self noteView:self viewControllerForRowAtIndexPath:path]; viewController.navigationController.navigationItem.leftBarButtonItem= nil;
you need a * after NSIndexPath and TDListViewController
i understand
TDListViewController viewController = (TDListViewController *)[self noteView:self viewControllerForRowAtIndexPath:path];
it's return me right TDListViewController with right variables
try performing [noteView reloadDataAnimated:NO]; after the change if (toState == KLControllerCardStateDefault) { NSIndexPath path = [self indexPathForControllerCard:controllerCard]; TDListViewController viewController = (TDListViewController *)[self noteView:self viewControllerForRowAtIndexPath:path]; viewController.navigationController.navigationItem.leftBarButtonItem= nil; viewController.navigationItem.leftBarButtonItem= nil; [self reloadDataAnimated:NO]; }
if i run this code, i have exception:
Terminating app due to uncaught exception 'NSRangeException', reason: '*\ -[_PFArray objectAtIndex:]: index (2147483647) beyond bounds (2)'
Note you can also get the uiNavigationController reference by simply doing controllerCard.navigationController
Maybe the problem in my
(UIViewController )noteView:(KLNoteViewController)noteView viewControllerForRowAtIndexPath:(NSIndexPath *)indexPath {
//Initialize a blank uiviewcontroller for display purposes UIStoryboard st = [UIStoryboard storyboardWithName:[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"] bundle:[NSBundle mainBundle]]; TDListViewController viewController = [st instantiateViewControllerWithIdentifier:@"ListRootViewController"]; viewController.list = self.listsData[indexPath.row]; //Return the custom view controller return viewController; }
You need to have * after UIStoryboard and TDListViewController. You are initializign a pointer
Be sure you understand what the * actually means in the context of assignment
you must be getting warnings for that no?
I understand, i paste this piece of code from xcode, but in xcode i have * when it's nessesary, but there * are hidden. So strange
ahhh ok I thought you were just not using them and was wondering how it was even working :P
If I did not have *, my code won't be compiled
I try a dirty hack. i add viewController property to KLControllerCard. @property (nonatomic, strong) UIViewController* viewController;
And in reloadData add: UIViewController* viewController = [self noteView:self viewControllerForRowAtIndexPath:[NSIndexPath indexPathForRow:count inSection:0]];
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
KLControllerCard* noteContainer = [[KLControllerCard alloc] initWithNoteViewController: self
navigationController: navigationController
index:count];
// i add this line noteContainer.viewController = viewController;
And now in -(void) noteViewController: (KLNoteViewController) noteViewController didUpdateControllerCard:(KLControllerCard)controllerCard toDisplayState:(KLControllerCardState) toState fromDisplayState:(KLControllerCardState) fromState { if (toState == KLControllerCardStateDefault) { [((TDListViewController *)controllerCard.viewController) updateUI]; }
}
Do you think it looks like a patch to your component? :P
Hi! I want to delete buttons from navbar in contollers when i go to KLControllerCardStateDefault state, but I did not get.
I tried to do:
-(void) noteViewController: (KLNoteViewController) noteViewController didUpdateControllerCard:(KLControllerCard)controllerCard toDisplayState:(KLControllerCardState) toState fromDisplayState:(KLControllerCardState) fromState {
if (toState == KLControllerCardStateDefault) { NSIndexPath path = [self indexPathForControllerCard:controllerCard]; TDListViewController viewController = (TDListViewController *)[self noteView:self viewControllerForRowAtIndexPath:path]; [viewContoller updateUI]; }
}
// updateUI in TDListViewController -(void)updateUI1 { self.navigationItem.leftBarButtonItem = nil; }