I have a an app in IOS 6. Now i am try to make it compatible with IOS 7.
I have a search bar controller. All works good in IOS 6. I have used UISearch Display Controller.
But in IOS 7 content size of table view not set correctly.
While i dont search any thing :
But if i search any anything than click on list view and scroll i have this out put :
![enter image description here][2]
You can see the white space below.
- (NSInteger)tableView:(UITableView *)tableView1 sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
if (title == UITableViewIndexSearch) {
[tblData scrollRectToVisible:self.searchDisplayController.searchBar.frame animated:NO];
return -1;
}
}
Thanks for Help
As you mentioned in the comment, you have a custom cell, maybe with custom layout and view hierarchy. Be sure to add views to the cell's contentView instead the cell, that is changed in iOS7.
Related
Auto layout is disabled.
On the view I have UINavigationBar at the top.
I have added UITableView in the XIB file (grouped) and set it in the IB to be at the top just bellow navigation bar.
But some strange gaps are displayed like on the images bellow.
I can't figure how to setup this layout I don't know from where gaps are comming. Any help (I use IOS 7 xcode 5)?
UPDATE
When I add your code:
Then I have tried from xcode again:
Simple set height of header 0.00001, if you set 0 it will be use auto value.
- (float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0.00000001;
}
From Interface Builder
Result
Set edgesForExtendedLayout of your controller to uirectedgenone
So I read here that I can simply drag a UITableViewCell to the bottom of my UITableViewController in storyboard and have it act like a footer. This footer row has an activity indicator in it that's it. It's width is 320 and height 55 with the indicator centered in the row. Note that it's a UIView rather than a UITableViewCell because I can only get it to work with the former.
First, The UITableView doesn't stop at the footer. One can see the footer if he extends his scrolling beyond the bottom of the UITableView. As soon as the user releases his finger, the footer disappears from site as the UITableView returns its scrolling back to the last element. I am trying to do what Instagram is doing - if you scroll to the bottom you can see their custom activity indicator at the bottom and the UITable will remain its scrolling position at that indicator. How can I achieve this?
Second, I have some custom scrolling performed by certain user actions. Right now, I have the following code:
if (row + 1 < [self.tableView numberOfRowsInSection:0]) {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:row+1 inSection:0]
atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
} else {
// TODO scroll a little down so the user can see the activityIndicator
}
How can I tell my tableView to scroll programmatically to the footer and have it stop there?
Third During the very beginning, my UITableView has to fetch things from my server before it can populate the tableView. Unfortunately i can't get the footer view to maximize the space of the UITableView so that the activityIndicator will appear in the center. Right now this is how it looks:
I think I have the structs set correctly:
I suspect that having a UIView within a UITableView might prevent the view from maximizing.
Summary
Any recommendations on the above issues? I apologize for the length of this question, but I feel that they are all related to the same problem mentioned above.
I finally figured it out.
With regards to #zing and #Lithu answers, that worked. However, returning a footerView from this method forces the footerView to "stick" to the bottom of the TableView. By this I mean that the footerview will always be shown (which is not something I want)
I finally used self.tableView.footerView = MyView. I disabled ALL the spring and struct settings on my UIView and it fits perfectly. (I've previously set it to maximize hoping to have it maximize when there is nothing in the table)
Regarding centering the activity indicator: I ended up setting the footer view to hidden if there's nothing in the UITableView (by checking in numberOfRows). I programmatically added the ActivityIndicator in the center if this occurs.
Thanks for all the answers!!
Did you try to do it in the proper delegate for UITableview Footer
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
Use This code to add any view in the footer.
e.g.
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, self.tblView.frame.size.width, 49)];
return footerView;
}
I added UISearchBar as tableHeaderView for UITableView in xib, by just dropping UISearchBar onto UITableView.
It is working fine, when the table has more than 6 rows.
But when there is less than 6 rows, it UITableView does not scroll.
At the same time, if i add the UISearchBar as tableHeaderView for UITableView programatically in .m file using the following statement, EVERYTHING WORKS FINE.
tableViewTemp.tableHeaderView = searchBarFriends;
Seems very strange to me,
What might be the problem?
Please advice, Thank you.
Here is a little trick I did ;) Don't make your SearchBar a subview of your UITableView. Just add instances of them both in your nib file and wire them up as IBOutlets in your UITableViewController. Then what you are going to do is set the SearchBar as the header view for your table, that way you don't have to worry about the frames overlapping and interfering with touch events. Here's how you do it:
Create the property in your TableView header file
#property ( nonatomic, retain ) IBOutlet UISearchBar *searchBar;
Set the header view for your table:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return self.searchBar; // The property you wired up in IB
}
Set the height for your header or (UISearchBar)
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 44; // The height of the search bar
}
That's all you need. Now this may not be the best solution if you have a grouped tableview or a table with multiple sections but its a clean solution for a simple table. Otherwise, you'd have to adjust the frame of the searchbar AND the tableview in code because they overlap and thats why you have touch issues. Hope this helps!
if you add search bar like below hierarchy it will work
I had almost the same problem (for me it wouldn't scroll at all with any number of rows, but it would as soon as I removed the search bar). Fixed it adding this in viewDidLoad:
self.tableView.alwaysBounceVertical = YES;
The iPhone's settings application is build around a UITableview. In some views there are additional texts between cells. For example in "Settings" -> "General" -> "Network" there is the text
"Using 3G loads data faster, but may descrease battery life" under a cell with an UISwitch. Any ideas how to implement this?
Images of what I mean can be found here:
http://www.tipb.com/2008/07/12/how-to-disable-3g-on-the-iphone-3g-for-more-talk-but-less-speed/
If you have a grouped table view, the tableView:titleForFooterInSection: method found in the UITableViewDataSource protocol and the UITableViewController class handles this for you:
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
if (section == 0) {
return #"Footer text for first section, goes below cells in that group.";
}
return nil;
}
To place that text between cells, you have to have multiple sections and tell your tableView:cellForRowAtIndexPath: method to place cells that you want beneath that text in the next section.
In XCode 6.1 you can specify footer text for Table View Sections in the Story Board.
Select your TableViewControler in the Story Board, then select the TableViewSection that you want the footer on. Then in the Attributes Inspector, in the Footer field, enter your text.
You can also create your own UIView of any type (images, texts etc) and add them to the table cell, by using the [[mycell contenView] addSubView:WHATEVER_IS_MY_VIEW_TO_ADD];
Is it possible to have the icons in a TabBar and / or the "More navigation controller" be in colors other than grey and black? I tried changing the color of the icon I set for the view controller using UITabBarItem's
- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag
method.
My client thinks the interface is too dark and want's to brighten it up with some colorful icons...
Thanks!
Coming a bit late to this but my approach to change the More controller icons was to (and not sure if Apple will approve it) do the following:
id moreNavController = [tabs.moreNavigationController.viewControllers objectAtIndex:0];
if ([moreNavController respondsToSelector(#selector(view)]) {
UITableView *t = (UITableView*)[moreNavController view];
[t setDataSource:self];
}
Then I just implement the UITableViewDatasourceProtocol methods
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{
id o =[tabs.moreNavigationController.viewControllers objectAtIndex:0];
return [o tableView:tableView numberOfRowsInSection:section]; //let the existing data source actually return the number of rows
}
and
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
/* configure cell as normal with what ever image in the imageView property*/
cell.imageView.image = <someimageobj>
}
Nope :( The buttons on a tabbar or toolbar are drawn with the alpha channel so they don't have color although the .png has.
So, you can subclass the TabBar or ToolBar and implement your own buttons drawing the entire bar.
Another idea is to have another XIB file that acts as a toolbar or tab bar of sorts. You can make it look exactly the same and even animate into view like a toolbar or tab bar would. You can then pass global variables through the App Delegate or via a Singleton to share with the other active view if necessary.
A good example of adding a subview into the view is the "Hidden Drawer" example code found here (just change the screen dimensions since this version pops the view in at the top, whereas you want it at the bottom).
http://cocoawithlove.com/2009/05/intercepting-status-bar-touches-on.html
If you can't figure it out, let me know and I have working code at home that I can post up here for you.
Rob