View which is always on top in Photoscroller Example - xcode

i would have a uiview which is always visible in every zoom scale.
in the loadView method in PhotoViewController.m i tried following:
[self.view addSubview:test];
[self.view bringSubviewToFront:test];
... with no success....
can someone help me?
greets, phil

as far as my knowledge there is a delegate method called after the zooming action
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
//write the bringsubviewtofront code here
}
It may works

Related

Change height of formSheet in iOS 8

I just have one question related to presenting a from sheet view controller in iOS 8. In iOS 7 I was able to change the height of the view controller using the last line of code in the function below:
SendRemainingEvaluationsViewController *sendRemainingEvaluationViewController = [[[SendRemainingEvaluationsViewController alloc] initWithNibName:#"SendRemainingEvaluationsViewController" bundle:nil]autorelease];
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:sendRemainingEvaluationViewController] autorelease];
navigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
//To Change the default size of the viewController which is presented in UIModalPresentationFormSheet presentation style
navigationController.view.superview.frame = CGRectMake(navigationController.view.superview.frame.origin.x, navigationController.view.superview.frame.origin.y, navigationController.view.superview.frame.size.width, 230);
But this does not work on iOS 8, not sure why? Does anyone knows what is the problem? any idea will be appreciated.
Thanks in advance.
After checking it, I could figure out the problem. After initializing the view navigation controller, its superview is nil and you can't access it right after presenting it. As a workaround, you can change the frame of its superview in the viewwillAppear of the view controller you're trying to present as you can see below:
- (void) viewWillAppear:(BOOL)animated
{
self.parentViewController.view.superview.frame = CGRectMake(self.parentViewController.view.superview.frame.origin.x, self.parentViewController.view.superview.frame.origin.y, self.parentViewController.view.superview.frame.size.width, 230);
}
This should work.

How to I launch a view controller from a tap gesture

Apologies if this is a basic question but I am new to Xcode and have a storyboard app and in the storyboard (with no segue) I have a view controller with an embedded map view.
On the storyboard screen I have an image with a tap gesture linked, I have tested the tap and it works (NSLog) but I want to know how to launch my mapview view controller and also zoom to an x&y.
My code currently has
-(IBAction)handleMapTap:(UIGestureRecognizer *)sender {
NSLog(#"Tapped");
}
& I have tried;
MMMapViewController *mapViewController = [[MMMapViewController alloc] initWithNibName:#"MapView" bundle:nil];
[self.navigationController pushViewController:mapViewController animated:YES];
My view controller has a class set as MMMapViewController I have given the view controller a storyboard id of MapView (if it's required?).
I've read a lot of stackoverflow articles but can't seem to find an answer. If anyone can help I would be really grateful.
-(IBAction)handleMapTap:(UIGestureRecognizer *)sender
{
MMMapViewController *mapViewController = [[MMMapViewController alloc] initWithNibName:#"MapView" bundle:nil];
//[self.navigationController pushViewController:mapViewController animated:YES];
[self presentModalViewController:mapViewController animated:YES];
[mapViewController release];
}
It would probably help to know what self is, if it is indeed a UIViewController, then
I would make sure that self.navigationController is not nil.
You actually have the right code, as far as I can tell, but depending on your scenario, you could get away with presenting the mapView as a modal view controller.

Remove a view of a class in Xcode

Hi
Is there a way to remove a view from another view of a specific class?
What I mean I have a view with multiple other views like a scrollview, imageview, tableview and I only want to remove the scrollview.
I thought the code would be something like this:
for (UIView *view in self.view.superview.subviews) {
if ([view.class == [Class UIScrollView]]]) {
[view removeFromSuperview];
}
}
But this didn't work. I could work with object at index: but because we don't know what index the scrollview has,so it also won't work. (I think)
Does someone knows the answer to this problem?
Thank you very much!
Is it this what you mean?
for (UIView *view in self.view.superview.subviews) {
if ([view isKindOfClass:[UIScrollView class]] ) {
NSLog(#"class");
}
}
If you can set an IBOutlet to the subview just call removeFromSuperview on the saved outlet.
(log the outlet to make sure it's set properly if that doesn't work)
(pretty sure that applies to both NSView and UIView)

Loading NSView from NIB won't work

I have this code to load an NSView from a NIB and add it to another NSView:
// INIT
- (void)awakeFromNib {
// Load nib
DNListViewController *listViewController = [[DNListViewController alloc] initWithNibName:#"ListView" bundle:nil];
// Add view to window
[listViewController.view setFrame:detailView.frame];
[detailView addSubview:listViewController.view];
// MEM
[listViewController release];
}
All outlets are connected right, but nothing shows up. I don't understand why! Can someone help me? Thanks.
This is about NSViews, not UIViews!
Oh, I fixed it already. Nevermind, I'll let is stay here for people from the future.
[listViewController.view setFrame:detailView.frame];
must be
[listViewController.view setFrame:detailView.bounds];

Clear and Redraw with Cappuccino (Objective-J)

basically I have this
#implementation MyView : CPView
{
CPArray MyPanelArray;
}
// Populate the MyPanelArray and position each panel
- (void)initMyView
{
...
}
MyPanels are pretty much wrappers for images. When everything is initialized it draws just fine. Then I have a slider to manipulate the position of the images and the only way I know how to redraw everything is to overwrite the MyView with a new instance and in the main contentView do something like
// Has the correct effect, but feels wrong
- (void)sliderAction:(id)sender
{
var myNewView = [MyView initWithPositionValue:[sender value]];
[_contentView replaceSubview:_myView with:myNewView];
_myView = myNewView;
}
It works all right, but I doubt thats the "right way".
*I know I can use a CPCollectionView for a basic setup, but its not going to work for what I'm trying to accomplish.
Thanks in advance.
By "redraw" do you mean actually doing a drawRect: or just moving/resizing the image views? If it's the latter then you can just call setFrame: on _myView.

Resources