Is there a way to show a UIImageView in front of a UIView (for Preview live)?
I try to make a camera based application so when clicking on a button the app take a pic and show it into UIImageView.
[myView addSubview: myImageView]
should work fine. if not please post your code.
If you are adding the view programmatically the previous suggestion should do it. If the views are in a storyboard or XIB and you want to move it to the front, try this:
[self.view bringSubViewToFront:myImageView];
You might want to use UIKit Peek and Pop if you are on iOS 9 or above.
Also there is this tutorial: http://useyourloaf.com/blog/3d-touch-peek-and-pop/
Related
I am using UITableViewController,UICollectionViewController in my app. On ViewDidLoad the view looks great like the following.
But after if I undergo its respective detail view and back to UITableView or UICollectionView it align like the following
I even tried setting self.tableView.frame = CGRectMake(0,0,width,height); on viewDidAppear but no luck.
Here is my tableView properties: (I also tried both check/uncheck these properties). Anyone here kindly suggest the possible solution or reason for this problem..
NOTE: Autolayout for storyboard is NOT used..
Put this code in your UITableViewController ViewDidLoad
self.navigationController.navigationBar.translucent = NO;
I'm just starting with iOS development and I was trying to achieve something that doesn't seem to work so far for me...
Here's the situation:
I have a nib file in which I have placed a UITableView, and just underneath a UIToolbar. That works just fine, the scaling is fine if I try different screensizes etc... So I was happy.
But here's the problem:
If the toolbar should be visible or not is a choice that a user can make somewhere in the application. However when the users selects to not see the toolbar I just call the method setHidden on the toolbar and pass it 'YES'.
The toolbar is now gone when I try this but the UITableView is not strechted to the bottom of the screen which gives me quite an ugly result.
So here's finally the question:
How can I automatically let the view stretch to the bottom when hiding toolbar? I guess I will have to do it in code (and not just some configuration option somewhere) but as I'm coming from Android this is somewhat strange for me.
Your best option will probably be to resize the tableview frame as you show/hide the tool bar.
CGRect frame = myTableView.frame;
frame.size.height += toolbar.frame.height;
myTableView.frame = frame;
Because you're using Auto-Layout, you'd want to create a height constraint for the UITableView and link it with your view controller via an IBOutlet. Then, to modify the height of the UITableView, simply do:
_tableViewHeightConstraint.constant += toolbar.frame.height;
You can even animate this with:
[UIView animateWithDuration:0.25 animations:^{
_tableViewHeightConstraint.constant += toolbar.frame.height;
}];
Note that you might need to call [_tableView layoutIfNeeded] after changing the height constraint.
I would like to put UIImageView that is shown on button click. That works good if I put it on the last place of Storyboard. The problem occurs when I do programatically some animation, and after that I click button for showing UIImageView and it is not on front position of the screen.
You can use bringSubviewToFront: method. Something like this:
[self.view bringSubviewToFront:imageView];
If you are adding and removing subviews, it can happen that the order of your views changes.
One solution is to leave the views where they are and only modify the hidden property or the alpha.
Another solution is to use insertSubviewAtIndex: instead of addSubview:.
Additionally, you can also use bringSubviewToFront: just to make sure.
I'm working on an app for a blog site, and I'm trying to keep the Default.png launch image up with a spinning indicator while I load the initial headlines into the tableview.
I set up a viewcontroller/view in my storyboard with the launch image and indicator.
I then have the following in the viewDidLoad: method of my navigationController's rootview
[self.navigationController presentModalViewController:[self.storyboard instantiateViewControllerWithIdentifier:#"SplashLoader"] animated:NO];
And once the headlines are loaded I use:
[self.navigationController dismissModalViewControllerAnimated:NO];
Am I way off base here? Or is this the right way to be doing this?
I've seen people doing something like this in app delegate, but that was before storyboards... If I'm supposed to be doing this in the app delegate then how do I instantiate the view controller out of the storyboard?
Thanks,
Any advice or suggestions would be appreciated.
The way I've done it is to make a UIImageView using the Default.png image. In viewWillAppear: I add it to the view controller's view property. In viewDidAppear: I use a UIView animation to fade out the image view by setting its alpha to 0. Upon completion of the animation, viewDidAppear: removes the image view from its superview and releases it (sets it to nil).
You have to keep a record of how many time viewWillAppear: and viewDidAppear: have been called because you only want this animation to happen when the app launches. Also, you have to think about which image to use to create the image view. If this is an iPhone app, you want to use Default.png. If it's an iPad app, you want to use Default-Portrait~ipad.png or Default-Landscape~ipad.png, depending on the orientation of the device when the app launches.
I'm not sure how you would accomplish the same effect in the app delegate. That seems like an unnecessarily complicated approach to me.
I have a simple app that has a NSStatusItem, which only displays an icon.
I would now like to add functionality that would make a MAAttachedWindow appear under the NSStatusItem.
I saw the demo code Matt Gemmel provided; the code he uses to make the MAAttachedWindow appear under the NSStatusItem is:
NSRect frame = [[self window] frame];
NSPoint pt = NSMakePoint(NSMidX(frame), NSMinY(frame));
[controller toggleAttachedWindowAtPoint:pt];
The above is done in the custom view of the NSStatusItem. However, my NSStatusItem has no custom view. How can I add the MAAttachedWindow in my case?
You can't afaik. You have to have a way to get coordinates to attach the window to, and the only way i've been able to get that to work is to use a custom view so you can get the coordinates on mouse down and the only way i've seen is to use your own view. Anything else would probably be a little hacky unless there is some way to get the view for a status item without a custom view and it wouldn't be good to display the MSAttachedWindow and a menu.
I just settled on doing a NSStatusitem with a custom view and faking selection by drawing a background gradient when its selected.
Have you considered using NSPopover ?