iphone popup custom size in IB - iphone

In my application I need show some info popup. This is just a text message above an image. When I create UIView for my popup in IB, it's size is non-ediatable (and equals to 320x460).
But my popup is not full-screen size.
Of course, I can create this popup programmatically, but I'd prefer data-driven approach.
So, the question is: how do I create custom-size UIView in IB?

If you set status bar of the view to none then you should be able to resize the view.

When a view is at the root level in an interface builder document it will always appear to be 320x460 but the size isn't actually set. Interface builder is just simulating what it will look like when it's actually loaded.
If this Popup view is actually supposed to appear in another existing view then drag it inside that view in IB. Once it's no longer at the root level you will be able to set its size.

Related

How To Prevent Interface Builder From Adding Items To A Custom View?

UPDATE: Edited for clarity.
This is not a showstopper, but it is annoying, and I'd like to figure out how to address it.
I have a custom UIView. A UIScrollView, to be precise, that is programmatically populated with a bunch of UIViews at runtime. It is not meant to have anything embedded in Interface Builder (IB).
What happens with any UIView, is that when you drag another element over it, the UIView becomes "droppable," and allows the other element to be dropped into it.
There are a few native Apple elements that won't let you drop stuff into them, like UIPickerView.
Is there a flag or something I can set, so that it won't allow IB to add anything to it?
Like I said, not a showstopper. If stuff gets added, it is destroyed before the programmatic population happens, but it just seems "neater" to make it clear that it's not "droppable."
UPDATE: In the screengrabs below, the Login Picker View is a standard UIPickerView, and the Display Results Scroller View is my custom scroller. If I drag something out of the Library, and try to drop it on the Picker View, nothing happens. However, I am able to drop it into my Display Results View.
What I want, is to be able to declare my Display Results View as a "no fly zone," so it is no longer droppable.
I hope that makes it clear.
Cannot Drop onto A PickerView
Can Drop On My Custom View
I'm not saying this is a great solution, but if you're using a storyboard (not a xib) then it seems to work…
In your storyboard, instead of dragging a scroll view out of the library, drag out a container view.
IB automatically creates a new storyboard scene connected to the new container view by an embed segue. Delete the newly-created scene.
Set the container view's custom class to UIScrollView.
IB does not allow you to add any subviews to a container view.
Note that IB also doesn't show you any UIScrollView-specific properties in the Attributes inspector, so if you need to customize this funky scroll view, you have to do it programmatically.
The library doesn't offer the container view in a xib, hence the storyboard requirement.

How to make a custom Swift popup window on iPhone

I'm wanting to implement a custom popup window within an iPhone app that contains buttons and labels.
One solution I've found is to simply create a hidden UIView in the same View Controller (How to make a popup window with an image SWIFT) and then making hidden = false. I feel like this shouldn't be the "best" way to do this, just due to the way I'll be working with multiple interfaces in the same View Controller.
Another method is forcing a non-fullscreen popover on iPhone (http://richardallen.me/2014/11/28/popovers.html), but this doesn't seem to play well with containing other elements like buttons and labels.
Is it possible to create a custom popup window for iPhone - which can hold buttons and labels - that can be implemented from a separate View Controller in my Storyboard? It has to be in a way that doesn't hide my main UI behind a fullscreen popover. Preferably one that can be easily animated using UIView.animateWithDuration.
Just looking for some starting directions so I can go learn more about implementing it. Or is stacking it with my other UI in the main View Controller the best way to go?
add a UIView container and make it's alpha = 0. If you want to show it you can increase the alpha to 1. And simply add a exit button to your container to decrease the alpha to 0.

UITableView has blank space below, can't remove

I have a UITableView that displays some data that is read in at runtime and features a button below it that will refresh the list when clicked. All of that works fine, however there is a problem with the layout on the simulator.
When I run, there is a space at the bottom of the table that pushes the refresh button down. No matter how long the UITableView is, the UIButton will always be kept at that extended distance. If I overlay the bottom with the UIButton, it does display with slightly less padding. I am at a loss of how to fix this.
Image with example of behaviour: http://img864.imageshack.us/img864/9913/screenshot20120326at113.png
I think the problem is that in the interface builder your layout does not show at the same size, because it lacks the navigation bar at the top.
In the visual editor, choose the window hosting your table view, go to the attribute inspector, and choose Navigation bar for the Top Bar entry in the Simulated Metrics section of the inspector. The layout of your design will change. Resize your table view, move your button, rebuild the app, and run it again; this should do the trick.
It looks like it's because you're designing without the navigation bar simulated and you've set up your autoresizing masks incorrectly.
What you can do is either enable the simulated metric (attributes inspector in IB with the main view selected) for the top bar set to Navigation Bar, or you can go and fix your autoresizing masks. They are the red things in the size inspector in IB.
It is because when you designed the screen you didn't consider the navigation bar that is gonna come. Simply add a bar to the screen on the top and rearrange the table and button with proper autoresizing masks. It will fit.

Scrolling through UIScrollView in Interface Builder for Xcode 4

This seems to me as though it would be a common problem, but I can't seem to find the answer anywhere. This question seems to address the issue, but I can't seem to get the solution to work and I'm not sure it's referring to Xcode 4.
When using Interface Builder in Xcode 4 and working with a UIScrollView, is there a way to scroll the view down in Interface Builder itself to view/add/edit controls that are out of the viewable section of the screen? I've managed to push a couple controls down using the arrow keys, but now I can't see them and therefore can't manipulate them in Interface Builder. Scrolling the view in IB would be first prize, but if there's a way to even select the controls using a drop-down menu or whatever so I can push them back up with the arrow keys, that would at least be something. Thanks.
Set the ViewController's Simulated Size to Freeform and set a very large height. E.g: 1000 and voilà! You can now scroll to see all the stuff and add even more! :)
P.S: Remember to set set Fixed when you are finish to avoid problems!
Just a workaround which helps in Xcode4:
Expand the Objects Panel which resides on the left of the Interface Builder view (there is the tiny arrow at the bottom of the panel).
Drag your UIScrollView from the view hierachy and place it on the top level.
Now you can resize it to access more content (scrolling to that content did not work for me).
When you are done adding child views to the scrollview, you need to resize it back to be smaller or the same size as the parent view.
After your changes you would need to put back the scroll view where it belongs in your hierachy
I typically do the following when I want to (have to) build a long scrolling screen:
Set the size of the View Controller to Freeform
Set the height of the top level View to something very large
Arrange all the controls that I want on the View
Select all the controls
Select Editor->Embed In->Scroll View
Set the size of the View Controller back to normal (typically Inferred)
Well, there are a few different things you can do. There is a list of items in your view you can open on the left of the workspace by clicking the button that looks like a little play button on the toolbar. Double clicking any item selects it so you can use the arrow keys.
The best option is to use the layout panel (typically on the right) and enter position values manualy. Sometimes I will use this to move my scrollview up to where I can see where I'm working then move it back.
I found a solution although you have to use a Table view controller. If you define the table as static, the scroll works in interface builder when the table is bigger than the windows size. Moreover, a standard view can be added to the top and bottom of the table, these views are scrollable as well. The scroll is made once the controller is selected. I hope you find this trick useful.
I know this isn't exactly what you were looking for, but I always just drag the scroll view out of the view controller onto the "pasteboard" where you can resize it at will and see the whole thing.
Once I make my edits I simply resize it to fit it's allotted space in my view and place it back in the view controller.
set the root view to freeform and ~1000 pt height, go through the child views and set them to this height as well(including scroll view), in the viewdidload method set the height to the appropriate size.

Moving and existing UI on a UIScrollView

I have some xibs with all sorts of text controls (UITextFields, UITextViews). Since the keyboard obscures some of these text controls when text input starts, I followed Apple's guideline for managing content located under the keyboard.
In short, the solution involves moving all interface elements on a UIScrollView. Doing it from Interface Builder I simply add a UIScrollView on the view, make it the size of the view, send it to back and link it's referencing outlet to the file's owner view property.
In IB this all looks fine, and the UI elements appear above the UIScrollView. However when I run the program, the UI elements are nowhere to be found. Their IBOutlets however seem to get initialized so it looks like they are actually constructed. I've tried to set the UIScrollView alpha to 0 to see if they are placed behind it but I still can't find them. New items that are added to the UIScrollView however, seem to work fine.
This leaves me with the not so great option of rebuilding all my xibs where I need to do this change. It kind of looks like an Interface Builder bug to me. What do you guys think?
Well I've found a solution. It goes like this:
Drag a UISCrollView in IB's main window (where we have the File's Owner and First Responder objects).
Rescale it to the size of the initial view
Drag and drop everything from the original view to the scroll view.
Link the scroll view's referencing outlet to the file's owner view property.
Delete the old view from IB's main window.
#MihaiD
use tableview.contentOffset=CGPointMake(x,y);
I don't know if you really need a UIScrollView. See this question on SO it slides the parent view up.