A little background. i have two viewControllers each with their own objects, but i would like to put them into one viewController Scene.
In my ViewController2, there is an IBOutlet UIImageView *drawImage which is supposed to be connected to a UIImageView in the one viewController Scene which is ViewController1's view controller scene.
In the only view controller scene, this UIImageView is embeded on a View(lets call it View2) which belongs to the ViewController2 and in that controller is all the code responsible for recognising the finger strokes.
This View2 that i previously mentioned is sitting in another bigger View(lets call this View1). So it is like View2 in View1(main).
View1 = ViewController1 and the second smaller View2 = ViewController2.
Two different ViewControllers(.h & .m), 1 View Controller Scene in storyboard.
Any idea how i can achieve it?
I think the answer I gave here will work for you. A container view is used to load your two different views. You can put the code in a method which is called when you recognize gestures or button presses or whatever.
Related
I have a UIViewController being presented with a UIViewControllerAnimatedTransitioning object to do the animation. The animation has a collection view cell expand and fade out as the new view controller's view fades in, expanding in the same way. So it looks like you have an expanding cell that transforms into the new view controller. But weirdly enough, the subviews of the cell get transformed in weird ways when they use auto-layout. When I don't use auto-layout, this doesn't happen. What might be the issue?
Try adding your cell to [[transitionContext containerView] superview] in - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext, instead of [transitionContext containerView]
For some reason this worked for me
I have a UIViewController embedded in a UINavigationController. The rootViewController now contains already some buttons as leftBarButtonItems.
Now when I push a new UIViewController on top of the UINavigationController I want the new UIViewController to keep the existing leftBarButtonItems extended with the Back-Button.
Right now the situations is as follows: When I push the new UIViewController then the existing leftBarButtonItems disappear and only the Back-Button is visible.
Each UIViewController has it's own "navigationItem" property, which acts as the navigation bar representation for that viewcontroller. When you add buttons to the navigationItem of a particular UIViewController they are limited in scope to the viewcontroller to which they were added, and they don't persist into other viewcontrollers.
Basically, you'll have to add the buttons to the navigationItem of each viewcontroller as it loads. You can make this simpler by writing adding a method to do this work to a class other than your UIViewControllers. What happens when you touch each button might be viewcontroller specific though, so you'll have to think through how touch actions will be fed back to the relevant viewcontroller. Perhaps introduce some kind of NavigationBarDelegate protocol or something?
I found what seems like a hacky way to get around this when pushing multiple instances of the same view controller on to a detail view controller which I assume would work similarly. Before pushing the new view controller I used this: (browser is my new view controller)
self.browser.navigationItem setLeftBarButtonItem:self.detailViewController.navigationItem.leftBarButtonItem animated:YES]; // Sets popover view controller button.
[self.detailViewController.navigationController pushViewController:self.browser animated:YES];
This probably isn't a good way to do it but it seems to work in my situation.
Simple question, I think.
Whenever I add an object like, a button for example, in my View Controller, in the Storyboard, it fills all the screen of the device. Can't figure out why.
Any advices ?
You are not adding UIButton to the UIViewController directly, right ?
You first need to add a UIView on the controller and then add objects to that view.
I have a puzzling problem. Working on a cocoa app in mac os x 10.7.
My app main window contains a split view. In a certain use context in one of the subviews of the split view is loaded a custom view with some labels (nstextfield) and a split view (instantiating a view controller that loads a nib and getting view from that controller). Frame of the custom view is set to split view subview bounds and everything works fine.
Problem is that one of the subviews of the second split view should be loaded (same method: view controller-nib-view-frame/bounds) with a custom view containing a table view and a button, but in this case nothing shows. Everything is done the same way but last custom view is not visible. Any idea?
Thanks
(edit)
this is the code I use to instantiate controller for the view to be added, get the view, and add it as subview to a subview of the split view
- (void)loadSubview {
self.subviewToAddController = [[viewController alloc] initWithNibName:nil bundle:nil];
//nib name is coded in the controller class definition
[[self.subviewToAddController view] setFrame:[self.splitViewContainerSubView bounds]];
//container subView is an outlet
[self.splitViewContainerSubView addSubview:[self.subviewToAddController view]];
}
However I don't think the problem is in this code because if I ask the container subview for its own subviews I can see the new subview is present in the list. It just doesn't show. If I add it as a subview of the split view (a test a just made) or as subview of the subview of the most external split view it is correctly showed too (sorry for the confused explanation, I would need a diagram but in this moment I can't make it)
To elaborate more my doubt (I didn't want to misled so I didn't mention before) can't it be a problem of coordinates, so view is correctly loaded and added as subview but is not visible because hidden by something or showed out of visible area?
(update)
Sorry it took so long to post an update.
After more testing I found out the problem is related to autolayout. No idea what the exact problem is and how to solve it. I ended up turning it off for the nibs the were in troubles and use the old way to set interface objects position and size/resize. Not the best way but for now I can go on.
My best guess is that you didn't set the autoresizing masks of the view properly.
I have a controller view. This controller has a PDFView as a subview and another subview which is like a controller to the pdf.
The problem is that if I do the following in the controller:
self.view addSubview:pdfView];
[self.view addSubview:pdfController];
The pdfController lays on the pdfView, but it will scroll with the pdf if you scroll it. I want to make pdfController view to be immobile and to just sit on the pdfView. Does anyone know how to get this behavior?
I remember having similar trouble trying to overlay an NSView over a PDFView with an app I was writing a few years ago. Assuming you've tried messing with the NSScrollView's copyOnScroll and the various autoresizing options, a good solution is to put the controller view in a separate child window that overlays the window your PDFView is in. You'll need to do a little work to synchronize behavior between the two windows, but in the end you won't have any of the weird problems that happen when you try to overlap sibling views like that.