- Registriert
- 20.12.14
- Beiträge
- 14
Ich wünsche euch ein schönes neues Jahr 2016
Hallo ihr, hab mal eine Frage an die ob mir jemand helfen kann.
Ich hänge bei einem Problem fest, ich will mein komplettes Projekt nur ab iOS Version 8.1 bereitstellen.
Nun hab ich das Problem ich komme beim UISearchDisplayController ( dieser wird ja seit 8.0 nicht weiter "unterstützt" ) nicht weiter.
Hier mal die Header Datei
Hier die .m Datei
Ich hoffe mir kann jemand helfen den Code mit z.B. if (tableView == self.searchDisplayController.searchResultsTableView) auf UISearchController "umzustellen".
Ich habe es schon mit if([UISearchController class]) probiert, hat aber nicht funktioniert.
Gruß Markus
Hallo ihr, hab mal eine Frage an die ob mir jemand helfen kann.
Ich hänge bei einem Problem fest, ich will mein komplettes Projekt nur ab iOS Version 8.1 bereitstellen.
Nun hab ich das Problem ich komme beim UISearchDisplayController ( dieser wird ja seit 8.0 nicht weiter "unterstützt" ) nicht weiter.
Hier mal die Header Datei
Code:
#import <UIKit/UIKit.h>
#import "StatBestimmtView.h"
#import "GleichgewView.h"
#import "KraftDrehmomentView.h"
@interface StatMenView : GAITrackedViewController <UISearchBarDelegate, UISearchControllerDelegate>
{
UITableView *ivMainTableView;
NSMutableArray *arryweiterFunktionen;
}
@property(strong,nonatomic) NSMutableArray *filteredCandyArray;
@property IBOutlet UISearchBar *candySearchBar;
@property (nonatomic, strong)StatBestimmtView* statview;
@property (nonatomic, strong) IBOutlet UITableView *mainTableView;
@property(nonatomic, strong)KraftDrehmomentView* momentview;
@property(nonatomic, strong)GleichgewView* gleichview;
@end
Hier die .m Datei
Code:
#import "StatMenView.h"
@implementation StatMenView
@synthesize momentview,statview,gleichview, filteredCandyArray, candySearchBar;
@synthesize mainTableView = ivMainTableView;
- (void)viewDidLoad {
[candySearchBar setShowsScopeBar:NO];
[candySearchBar sizeToFit];
CGRect newBounds = [[self mainTableView] bounds];
newBounds.origin.y = newBounds.origin.y + candySearchBar.bounds.size.height;
[[self mainTableView] setBounds:newBounds];
self.automaticallyAdjustsScrollViewInsets = NO;
self.navigationItem.title = NSLocalizedString(@"statik", nil);
arryweiterFunktionen = [[[NSArray alloc] initWithObjects: NSLocalizedString(@"statfachti", nil), NSLocalizedString(@"Moment", nil), NSLocalizedString(@"Gleichgewicht", nil),nil] mutableCopy] ;
filteredCandyArray = [NSMutableArray arrayWithCapacity:[arryweiterFunktionen count]];
// Reload the table
[[self mainTableView] reloadData];
[super viewDidLoad];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView){
return [filteredCandyArray count];
}else {
return [arryweiterFunktionen count];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if (tableView == self.searchDisplayController.searchResultsTableView)
{
cell.textLabel.text = [filteredCandyArray objectAtIndex:indexPath.row];
}
else
{
cell.textLabel.text = [arryweiterFunktionen objectAtIndex:[indexPath row]];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == self.searchDisplayController.searchResultsTableView)
{
if([[filteredCandyArray objectAtIndex:indexPath.row ]isEqual:NSLocalizedString(@"statfachti", nil)]) {
StatBestimmtView *viewTwo = [[StatBestimmtView alloc] initWithNibName:@"StatBestimmtView" bundle:[NSBundle mainBundle]];
self.statview = viewTwo;
[self.navigationController pushViewController:self.statview animated:YES];
}
}
else{
if([[arryweiterFunktionen objectAtIndex:indexPath.row ]isEqual:NSLocalizedString(@"Gleichgewicht", nil)]) {
GleichgewView *viewTwo = [[GleichgewView alloc] initWithNibName:@"GleichgewView" bundle:[NSBundle mainBundle]];
self.gleichview = viewTwo;
[self.navigationController pushViewController:self.gleichview animated:YES];
}
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ( [[segue identifier] isEqualToString:@"candyDetail"] ) {
UIViewController *candyDetailViewController = [segue destinationViewController];
if(sender == self.searchDisplayController.searchResultsTableView) {
NSIndexPath *indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
NSString *destinationTitle = [[filteredCandyArray objectAtIndex:[indexPath row]] name];
[candyDetailViewController setTitle:destinationTitle];
}
else {
NSIndexPath *indexPath = [self.mainTableView indexPathForSelectedRow];
NSString *destinationTitle = [[arryweiterFunktionen objectAtIndex:[indexPath row]] name];
[candyDetailViewController setTitle:destinationTitle];
}
}
}
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope{
[filteredCandyArray removeAllObjects];
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF contains[c] %@", searchText];
filteredCandyArray = [NSMutableArray arrayWithArray: [arryweiterFunktionen filteredArrayUsingPredicate:resultPredicate]];
}
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString{
[self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
return YES;
}
@end
Ich hoffe mir kann jemand helfen den Code mit z.B. if (tableView == self.searchDisplayController.searchResultsTableView) auf UISearchController "umzustellen".
Ich habe es schon mit if([UISearchController class]) probiert, hat aber nicht funktioniert.
Gruß Markus