Resize UIView from point with animation - objective-c

I have UIButton on view, when I taped on this button I want to create new view and display it on iPad screen, how I can view this view like growing from button to full screen ?

Next time actually show some effort with what you have tried etc when asking for help
- (void)buttonTapped:(UIButton *)button;
{
UIView *expandingView = [[UIView alloc] initWithFrame:button.frame];
expandingView.backgroundColor = [UIColor redColor];
[self.view addSubview:expandingView];
[UIView animateWithDuration:.25f
animations:^{
expandingView.frame = self.view.bounds;
}];
}

On the button click event.
Create the view with frame with size zero and orgin as center of
button
2.add to mainview
3.Then using animation block change
the frame to orginal
What are block-based animation methods in iPhone OS 4.0?
use this qn to find how to add animation

Related

Moving the contents of a view rather than the view itself

I am creating my own slide menu which is pretty simple.
I am creating a subview, adding it to the view and then sliding the self.view to the right by 170px which reveals the new subview (named secondView).
However, none of the buttons on the new view are clickable after moving the self.view to the right (as they were before I did this). So I image that because the view has moved, the view is the clickable region of the app.
Is there a way to move the content across as opposed to the view to allow the new view to be clickable.
The problem is:
Touches outside of a view's frame never trigger events to its subviews.
I mean, touches outside of self.view.frame never trigger event to secondView that is one of subviews of self.view.
see: Event Handling Guide for iOS
You can [self.view.window addSubview:secondView] and move both self.view and secondView.
[self.view.window addSubView:secondView];
CGRect viewFrame = self.view.frame;
CGRect secondFrame = secondView.frame;
viewFrame.origin.x += 170;
secondFrame.origin.x += 170;
[UIView animateWithDuration:0.2 animations:^{
self.view.frame = viewFrame;
secondView.frame = secondViewFrame;
}];
Note:
Above code may cause troubles if self is not window's rootViewController. e.g. in UINavigationController.

Set a UIPickerView to bottom of UITableview regardless of scroll position

I'd like to present a UIPickerView snapped to the bottom of a UITableView regardless of where it is scrolled.
Currently I have a UIPickerView added to a UITableView that I present when a button is pressed, but when I scroll the table the UIPickerView goes out of view, and if I'm scrolled out of range of where I've presented it, the UIPickerView appears to have never been called.
Does anyone know how to accomplish this?
Thank
The use of UITableViewController is great unless you need to add subview that don't scroll with the table view. It can't really be done. The solution is to use a UIViewController instead and add your own table view, setup the table view dataSource and delegate protocols and replicate the basic table view controller plumbing.
Once your view controller works like a normal table view controller again, you can now add subviews to the view controller's view that won't scroll with the table.
if u add tableview programatically
SearchtableView.frame = CGRectMake(450, 90, 318, 600);
SearchtableView = [[UITableView alloc] initWithFrame:CGRectMake(623, 90, 400, 400)style:UITableViewStyleGrouped];
[self.view addSubview:SearchtableView];
//belove the tableview//
//Add UIPickerView to the self.view]//
Something told me that there must be a simpler alternative to the answers that I'd been given, and I found a solution.
I decided to find the y coordinate of the scroll point using scrollViewDidScroll: and then animating the UIPickerView to the desired location.
...
[UIView beginAnimations:nil context:NULL];
CGFloat pointY = self.scrollPoint.y;
[self.sortPicker setFrame:CGRectMake(0, pointY + 200, 320, 216)];
[UIView commitAnimations];
...
The UIPickerView will only appear if the scroll has been stopped so it's necessary to implement a method to stop the scroll on touch:
- (void)stopScroll:(UITableView *)tableview
{
CGPoint offset = tableview.contentOffset;
[tableview setContentOffset:offset animated:NO];
}
This will allow you to display and dismiss the UIPickerView at any moment at any given destination.

iPad: Popover windows got resized iOS

CGRect rect = CGRectMake(0, 0, 1050, 900);
[wineAdminPopup presentPopoverFromRect:rect inView:master.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Hi I put the above code to make a popup in a tableview. However it doesn't popup in the whole screen. If I want to center it in the iPad screen with no arrow or arrow in the center. How can i do it. Thanks in advance.
The rect parameter in presentPopoverFromRect:... specifies the rectangle at which to anchor the popover, not the size of the presented popover. That would be specified by setting contentSizeForViewInPopover on the popover's content view controller.
If you don't want the arrows and don't need the specific behavior of popovers, then you could
present your view controller modally:
controller.modalPresentationStyle = UIModalPresentationFullScreen; // or UIModalPresentationFormSheet
[self.navigationController presentModalViewController:controller animated:YES];
presentModalViewController is deprecated in iOS 6 and above. Use presentViewController:yourViewController animated:YES completion:nil (parameters animated and completion can be set depending on your requirements). Also if you want to resize yourViewController you need to change self.view.frame and next time your view controller will be of that size.

I would like to implement a half UITableView half MapView UIView with a button in the middle

Well, this is what I want to do in my app: I would like to implment a UIView with a map on the top half of the screen and a tableview on the other half with two buttons in the middle. If I press one of the buttons the map will get fullscreen and if I press the other one the tableView will fit all the screen.
Any suggestion?
In one view controller like a UINavigationController create an MKMapView with a frame the size of the top half of the view and add it as subview of your view controller. Then I would create a UIToolbar to hold your buttons and make the top of it's frame line up with bottom of the MKMapView. Finally create a UITableView with it's frame just below the others (make sure you hook up it's delegates).
Then assign the target of your UIBarButtonItem that makes the map go fullscreen to a method that animates the frames of all three views like this:
[UIView animateWithDuration:0.24
delay:0.0
options:UIViewAnimationCurveEaseOut
animations:(void (^)(void)) ^{
self.toolbar.frame = CGRectMake(0, MAP_HEIGHT_FULLSCREEN, 320, TOOLBAR_HEIGHT);
self.mapView.frame = CGRectMake(0,0,320,MAP_HEIGHT_FULLSCREEN);
self.tableView.frame = CGRectMake(0, MAP_HEIGHT_FULLSCREEN+TOOLBAR_HEIGHT, 320, MAP_HEIGHT_FULLSCREEN-MAP_HEIGHT);
}
completion:^ (BOOL finished){}
];
Create both views how you are planning, On one button click, change the frame of one view to fit the full screen, if you click the other button, do the same thing to the other view.

UIColor groupTableViewBackgroundColor is transparent

I have a grouped style UITableView on my navigation stack, and when I click on a cell, I push a UIDatePicker onto the stack. The problem is that I want this custom view to have the same background color as my table view.
I tried setting the background color of my custom view like:
datePicker.backgroundColor = [UIColor groupTableViewBackgroundColor];
But this comes out transparent. I also tried modifying the underlying CGColor object to have an alpha of 1.0, which caused the background color to be black.
The following does work as expected:
datePicker.backgroundColor = [UIColor lightGrayColor];
But, of course, this color doesn't quite match the grouped table background color.
Am I going about this all wrong? I found a similar post about this here, but no helpful response.
What do you mean you "push a UIDatePicker onto the stack"? Why dont you try animating the UIDatePicker into view?
when the view loads, create the picker and set the frame off screen, such as
[picker setFrame:CGRectMake(0,960,320,216)];
then instead of "pushing" the picker, animate it into view like:
[UIView beginAnimations:nil context:NULL];
[picker setFrame:CGRectMake(0,200,320,216)];
[UIView commitAnimations];
And when you want to dismiss the picker, just hide it like:
[UIView beginAnimations:nil context:NULL];
[picker setFrame:CGRectMake(0,960,320,216)];
[UIView commitAnimations];
If you need to, you can also add a toolbar with a "done" button to dismiss the picker, works great for me.
If the contents of the picker are going to be displayed on the table, then you can set the frame of the table in that animation sequence. in the first one, make the table half the size (like 150 for my example would work perfect), then in the hide sequence, make the table the original size (415 for this example). And when you hide the picker, call [tableView reloadData]; to refresh the table.