How to split an UIView - iphone

Ok, let's say we have an UIView (let's call it mainView) with the size of 480*320 (landscape), and I want to create 2 other views, one to display the first half of the mainView and the second will display the second half of the mainView and both of them will be 240*320, how can I do this?

It all depends on what is in the view at the first place.
If you have dynamic content like changing pictures you can just create two images from that with no problem but if you have UIButtons and other subviews then it's a lot of trouble. For instance what to do if a button or any other object lies in the middle of the main view. If you know your object will be position in either of two half's of the main view then you would go about splitting like this. Check all the subviews of the main view, depending on their position assign them to your new left or right view. The tricky part will be with the right view b/c you will have to adjust the x coordinate.

use the code and split it and replace the name by using the field name which present in the IB
..use picker view method

Related

Is it possible to avoid SuperViews when hitTesting?

Basically, I want to be able to click all the Subviews in the Image below...
I want to be able to tap the Subviews of View B but View A is in the way even though View A Subviews are not blocking the views below. Is this possible? In other words I want to be able to tap through the transparent parts of a view even though its frame/bounds cover that area. View B is under View A in a ScrollView.
thanks,
austin
The solution is to subclass View A (if it's not a custom view already) and override pointInside:withEvent.
Return YES if the specified point is inside one of View A's sub-views, or NO otherwise. When pointInside:withEvent returns NO the system will continue to try other views until it finds one that claims the point is inside it, then it will call hitTest:withEvent to see which inner-view to send the touches to (the default behaviour).

Group views in Interface Builder

Is there any way to move a group of views within another without grouping all in the center?
Edit:
Here some images with the process.
1.- I have a view with separate subviews (labels, buttons, images...)
2.- I create a new view (that will contain all the subviews)
3.- Select all the subviews and put them in the new super view.
4.- When the subviews are in the new "super"view, all of them are centered and I need to relocate all.
I found a very nifty solution that you are not gonna believe .. !
I had a group of like 30 labels and buttons positioned pixel by pixel, so I HAD to, no matter what, move them while preserving their relative locations to each other.. Here is what I did:
Select all the views (labels, button, ... etc)
Editor -> Embed In -> View. (Now, they are in a view)
Move that view wherever you like. (Heck, you can even cut and paste it to a new NIB!)
Selected the view, Editor -> Unembed ! :D
I haven't read this anywhere, I came up with it yesterday .. Am 100% sure people somewhere have found this way before me, though.
EDIT:
It seems Xcode 4.5 renders this answer obsolete. Copy/Pasting a bunch of views now retains their relative locations to each other. Don't bother with this if you grew a habit on using it!
Actually, I think this answer is still viable!
You can make one view except xib's main view add that view contain all imageview,label in this view like below image. Assign IBoutlet to the the ViewInvoiceNumber and when set frame add subviews will move according that view like group.. But you have to enter all label,button,image view as subview of that view..
Hope, this will help you...

iOS - UITableView Pan Gestures

This may turn out to be 2 questions in one, but I believe solving the first will go most of the way to solving the second.
First, I have created a view in Interface Builder (I know!) and I load the xib file into my view controller in the app delegate. All of this runs smoothly and as expected.
The view consists of 3 table views, two of a similar size and one small one in a corner.
A cell is added to one table view a pan gesture is added to allow movement around the scene.
However, if a cell is moved from it's table view, it appears to go BEHIND the parent view, as per the screenshot below:
The grey line between the two tables is the gray background of the parent view. If the user still has his/her mitts on the cell, they can drag it into view but how can I make it so that all table views are on the same 'layer'?
I.e. so that dragging a cell from one table view to another with show the cell hovering over both views.
This leads me onto my second question, which I will not ask yet as I believe the solution to this will solve my current issue. but I will explain for further clarity.
In my pan gesture, I use a point inside check to see if the cell is within a table view, currently panning a cell from any table makes it print. It is almost like the views take up the whole screen, even though they are sized not to?
All ideas welcome! Thanks!
This was solved by listening for the cell leaving the bounds of the table view, when this happened, I transferred the cell across the table view that it has been dragged to, adding it to the bottom of the list.
Not the most elegant solution and you do lose the touch but it does work,

Is it possible to put one UITableView over another UITableView in InterfaceBuilder?

I know I can use codes to add UITableView one by one.
[self.view addSubview:tableview1];//
[self.view addSubview:tableview2];//
I hope to do the same thing in InterfaceBuilder, when I drag one UITableView onto another one, the new one always pushes the old one to the bottom, rather than just stays over the old one of UITableView.
Welcome any comment
Thanks
If you have a parent view that will contain your tableviews then you shouldn't have any problem. If you're trying to place them directly in a window then I could see a problem. If things aren't lining up the way you want you can always change their position via the Size Inspector or by nudging them with the arrow keys (shift-arrow key moves in 10 pixel increments).
Why anyone would want a tableview on top of another tableview escapes me.
Your parent view should be a subclass of uiviewcontroller and your xib should have the root view as a uiview and not uitableview.
I used two overlapping table views to show two different contents on the same view, which could be toggles using a segment switch. Apparently my client requirements were vague enough that I couldn't just filter out data like how the phone app displays all calls/missed calls list.

Animating views

i have a tableview with multiple rows.row values dynamically changes every 2 secs except last row .i like to add a rotating view in the last row. how to add a animating view in the last row? how to rotate a view inside a tableviewcell? i'm not looking for a UIActivityindicator. i want to rotate my view around z axis.
If you're looking at how to show a UIActivityIndicator inside a table view cell, then the solution is simple.
In your table view cell subclass create an instance of UIActivityIndicator and add it as a subview.
You could add a subview to the cell view and present it with presentModalViewController although I am not sure if this will work in a non-fullscreen scenario.