UA-17470720-3

Jump to content


Photo
- - - - -

place new item detail view inside a popover


  • Please log in to reply
3 replies to this topic

#1 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 10 February 2014 - 05:21 PM

I have a SCViewController, that has go a UIButton on the view.

When the button is pressed i an trying to get the new item detail view to display inside a popover view from the button

the problem is that every time a dispatch add new item, it display the view controller modally

what am i missing here??

 

button tapped

- (IBAction)addNew:(id)sender {
    SCArrayOfObjectsModel *arrayOfObjectsModel=(SCArrayOfObjectsModel *)self.tableViewModel;
    arrayOfObjectsModel.newItemDetailViewControllerOptions.presentationMode = SCPresentationModeCustom;
    [arrayOfObjectsModel dispatchEventAddNewItem];
}

in my table model code i thought i could grab the new detail modal view and place it where i want.. but the detailModel view controller is anyways nil, as if its not yet created

objectsModel.sectionActions.detailModelWillPresent = ^(SCTableViewSection *section, SCTableViewModel *detailModel, NSIndexPath *indexPath)
    {
        if (!weakSelf.popoverController) {
            weakSelf.popoverController = [[UIPopoverController alloc] initWithContentViewController:detailModel.viewController];
        }
        [weakSelf.popoverController presentPopoverFromRect:weakSelf.addNewButton.frame inView:weakSelf.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    };

this code just is not the right way about it..

how can i get a hold of the new detail view and place it inside a popover??

 

EDIT**

going through the source code i see that handleDetailViewControllerWillPresent only passes the modal of the detailviewcontorller.. is there any way to get access to the view controller from a modal object?

if it also passed the view controller object itself i could then move move its popover controller manually to where i want it

 

as a stop gap fix.. i altered the source code for the SCTableViewSection.m line 2298

i added these lines to pass back the detailViewControl.. usually this property is ALWAYS nil.. so setting it here i can get hold of the view, then its popover and move it

SCArrayOfItemsModel *itemsModel = (SCArrayOfItemsModel *)self.ownerTableViewModel;
itemsModel.detailViewController = detailViewController;

really i should have altered line 2809 and added my 2nd line right after this line.. but thought it best that i only set this value when i want to make sure its a popover

Oz


Edited by ozie, 10 February 2014 - 07:58 PM.

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#2 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 545 posts
  • LocationIreland
Reputation: 137
Popular

Posted 11 February 2014 - 02:54 AM

Hi ozie,

 

SCPresentationMode doesn't appear in the documentation for some reason, but in SCViewControllerTypedefs.h there's a SCPresentationModePopover defined.

 

Does that not do what you are looking for?

 

Line 2298 in SCTableViewSection.m  is inside a switch on mode and is part of the SCPresentationModePopover case, it's not doing anything when mode is SCPresentationModeCustom is it?


Cheers,

Dave

www.dgapps.ie

#3 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 11 February 2014 - 03:08 AM

eau Dave.. i have tried all the different presentation modes.. 

i would have thought that setting it to popover i would have some extra control, but from the code i se that when its set to popover it checks for navigation bars and bar button items to display from, else it just displays from the tableview itself


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#4 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 11 February 2014 - 04:15 AM

i think I'm getting somewhere

in the SCTableViewModelDataSource there is a delegate method

- (BOOL)tableViewModel:(SCTableViewModel *)tableModel customPresentDetailViewController:(UIViewController *)detailViewController forRowAtIndexPath:(NSIndexPath *)indexPath;

and if i return TRUE none of the STV code runs.. but i have in the method the view controller.. so now i should be able to put that into a popover:)

 

this is the end code that works like a treat

- (BOOL)tableViewModel:(SCTableViewModel *)tableModel customPresentDetailViewController:(UIViewController *)detailViewController forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    detailViewController.preferredContentSize = CGSizeMake(320, 500);
    detailViewController.modalInPopover = YES;
    
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:detailViewController];
    
    self.popoverController = [[UIPopoverController alloc] initWithContentViewController:nav];
    [self.popoverController presentPopoverFromRect:self.addNewButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [(SCTableViewController *)detailViewController setPopoverController:self.popoverController];
    
    
    
    return YES;
}

Edited by ozie, 11 February 2014 - 02:33 PM.

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users