How to show the TableView (like dropdown) on Button Click in iPhone? - ios

I have tried this code. http://www.mediafire.com/download/bvoqrkn82sd6az9/tablesample.zip ..Here, It will display the Table View. But I need to create a tableview whenever I click the button, it should display the list of Tableview like dropdown as it is in this screenshot. http://www.mediafire.com/download/7jiwb0e00916gh9/Table+View.PNG This is what I need to display. Your help is highly appreciated. Thanks in advance.

You can change height of tableView with animation. Set time according your suitability.
For Expansion:
[UIView animateWithDuration:1
delay:0.0
options: UIViewAnimationYourChoice
animations:^{
CGRect frame = self.tableView.frame;
frame.size.height = 300;
self.tableView.frame = frame;
}
completion:^(BOOL finished){
NSLog(#"Done!");
}];
For shrinking:
[UIView animateWithDuration:1
delay:0.0
options: UIViewAnimationYourChoice
animations:^{
CGRect frame = self.tableView.frame;
frame.size.height = 0;
self.tableView.frame = frame;
}
completion:^(BOOL finished){
NSLog(#"Done!");
}];

There is no option for dropdwon in IOS SDK. If you need this follow like this.
On the click of this button you'll have to load a UIView or UITableView which will come exactly down to your UIButton.
This custom UIView or UITableView will act as your drop down.
Once your use is complete you can either hide it or remove it.
I hope it will hepl you.. Instead of dropview you can use UIPopoverController to show the UITableView

I have implemented this , You can achieve this by adding the button on the first row of any section and load other rows by the click on the first row with UITableViewRowAnimationTop using beginUpdate.
So now every first row of the section with index==0 will be a dropdown button and other rows starting from index=1 will be your data rows representing the information.

Related

Showing UIPickerView when cell is selected

For my app I’m implementing in-app settings using tableView with Dynamic prototype cells. Inside cell I’m showing main title and sub title. What I would like to achieve is when user clicks on one of the cells (that represents specific settings) the pickerView will slide from the bottom of the screen showing the options that user can pick. I’ve seen few tutorials where this pickerView is presented inside a cell as it is e.g. in iOS calendar app but I don’t need that – all will be fine if it will slide from the bottom actually in a same way as it is when you are having pickerView as inputView for your text field (e.g. textField.inputView = pickerView) and click to the text field. I appreciate any help you can provide guys! Thanks in advance!
You can create a custom view xib in which you can have pickerView,when user click on cell just show the custom view with animation.
viewPicker = CGRectMake(0, 490, 320, 460);
For the animation from bottom to top add below:
[UIView animateWithDuration:0.5
delay:0.1
options: UIViewAnimationCurveEaseIn
animations:^{
viewPicker.frame = CGRectMake(0, 0, 320, 460);
}
completion:^(BOOL finished){
}];
[self.view addSubview:viewPicker];
For removing the view
[UIView animateWithDuration:1.5
delay:0.5
options: UIViewAnimationCurveEaseIn
animations:^{
viewPicker.frame = CGRectMake(0, 490, 320, 460);
}
completion:^(BOOL finished){
if (finished)
[viewPicker removeFromSuperview];
}];

Hidding view with table scroll

I'm searching for idea how to implement a table view with moving view on top of it.
So the idea is something similar to navBar in facebook app. When you scroll up this (red) view is moving up and hiding, when you scroll up its going up and when you scroll down its revealed. This is not nav bar so most of the pods I've found are not working in this situation. This cannot be tableView header or section header as well.
You need added this view above table:
[self.tableView.superview insertSubview:view aboveSubview:self.tableView]
Or you can do it in storyboard.
When you table scroll down hide view, when up show.
[view setHidden:YES];
Also u could change table inset to the top of the superview.
self.tableView.contentInset = self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(self.tableView.contentInset.top -, self.tableView.contentInset.left, self.tableView.contentInset.bottom, self.tableView.contentInset.right);
I think fast way to do it use gesture recognizers to recognize reveal and hide actions and than you can use methods like below,
[UIView animateWithDuration:0.5 animations:^{
[attachedView setAlpha:0.0f];
} completion:^(BOOL finished) {
[attachedView setHidden:YES];
}];
and for reveal attached view
[UIView animateWithDuration:0.5 animations:^{
[attachedView setAlpha:1.0f];
} completion:^(BOOL finished) {
[attachedView setHidden:YES];
}];
methods will help you to hide and reveal views gently.
Take a look at this library, it does exactly what you want to do
https://github.com/telly/TLYShyNavBar

Custom UIActivityViewController-like view that slides up and down

Is there a way to subclass or customize UIActivityViewController to create a sort of custom view? For example, see the image below from the app Overcast. I want to create a view similar to that, where if you tap a button, the view pops up and when you tap outside of the view, it slides back down.
Why not use an UIView ? Set it's initial frame's y value to -self.customView.frame.size.height and animate it's frame to the normal position using [UIView animateWithDuration]
-(void)showCustomView{
[self.customview setFrame:CGRectMake(0, -self.customView.frame.size.height, self.view.bounds.size.height+self.customView.frame.size.width, self.customView.frame.size.height)];
[UIView animateWithDuration:0.25 animations:^{
[self.customView setFrame:CGRectMake(0, -self.view.frame.size.height, self.view.bounds.size.height-self.customView.frame.size.width, self.customView.frame.size.height)];
}];
}
-(void)hideCustomView{
[UIView animateWithDuration:0.25 animations:^{
[self.customView setFrame:CGRectMake(0, -self.customView.frame.size.height, self.customView.bounds.size.height+self.customView.frame.size.width, self.customView.frame.size.height)];
}];
}
Add an UITapGestureRecognizer and call hideCustomView when tapped outside the customView

Toggling UITableViewCell selectionStyle causes labels on cell to disappear

I have a custom subclass of UITableViewCell. On my storyboard, it basically has a containerView (UIView *), that has some labels on it, and a UISwitch. I add a gesture to slide my tableViewCell to the right to show some detail controls underneath the containerView, and then another gesture to slide the original view back. The animation code looks like this:
- (void)showCustomControls:(UISwipeGestureRecognizer *)gesture {
[UIView animateWithDuration:0.3 animations:^{
[self.containerView setFrame:CGRectMake(self.frame.size.width - kTableViewCellSwipedWidth, 0, self.frame.size.width - kTableViewCellSwipedWidth, kOverviewTableViewCellHeight)];
}completion:^(BOOL finished) {
self.isReveal = YES;
self.selectionStyle = UITableViewCellEditingStyleNone;
}];
}
- (void)hideCustomControls:(UISwipeGestureRecognizer *)gesture {
[UIView animateWithDuration:0.3 animations:^{
[self.containerView setFrame:CGRectMake(-kTableViewCellBounceWidth, 0, self.frame.size.width, kOverviewTableViewCellHeight)];
}completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 animations:^{
[self.containerView setFrame:CGRectMake(-kTableViewCellBounceWidth / 2, 0, self.frame.size.width, kOverviewTableViewCellHeight)];
}completion:^(BOOL finished) {
[self.containerView setFrame:CGRectMake(0, 0, self.frame.size.width, kOverviewTableViewCellHeight)];
}];
self.isReveal = NO;
self.selectionStyle = UITableViewCellSelectionStyleBlue;
}];
}
I noticed if I left the selectionStyle on, with the row open, it looked kind of funny. So I wanted to turn the selectionstyle off. So the code in there is to turn on and off the selection style when the row is open or closed. It works, however the weird thing is, when hideCustomControls gets called, and my original row slides back into place, the labels on the container view all go away. I have a little edge of the original row that shows, and when that is showing, the labels are there. But the second that the row slides all the way in place, all the labels disappear. The UISwitch which is also on the containerView never has problems though. It is always present. Is there a reason why this may be happening? When I remove the selectionStyle code in both methods, this problem goes away. Thanks in advance.
Edit:
I put in the correct code to animate using NSLayoutConstraint. Now the problem is the UIView subclasses I have on the view underneath show through to the top view when my row slides back into place. Not sure why this happens...

how to add animation to a second view which is inside first view in xcode for ipad using storyboard

In storyboard, in a view controller i've added a scroll view.Inside it another two different views are added & named them as "firstview" & "secondview". When i press add button from "firstview" ,it will show SecondView which is kept as hidden during the initial run. Now i want to display that view by performing some animations. How to solve this?
[UIView transitionWithView:self.secondview
duration:5.0f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
self.secondview.alpha = 1.0f;
} completion:NULL];
tried these but not working
Thanks in advance....
Try the following code if your second view is hidden
[UIView transitionWithView:self.secondview duration:5.0f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
self.secondview.hidden = NO;
} completion:^(BOOL finished) {
self.secondview.alpha = 1.0f;
}];
If your self.secondview is hidden then you need to make it unhidden and set the alpha to 0. If the secondview is hidden that doesn't mean it's alpha is 0.
So use the same code but instead of make it hidden set the secondview.alpha = 0; or in your case make it from the storyboard.

Resources