ios 7 - Custom UIMenuItem not working on TableViewCell - ios

I am working on adding custom UIMenuItem on tableViewCell. I used this stackoverflow post to to add customMenuItem. This worked fine on ios 6. But it is not at all working on ios 7.
Below is the implementation I have:
In viewDidLoad:
UIMenuItem *sendByEmailMenuItem = [[UIMenuItem alloc] initWithTitle:#"Send By Email" action:#selector(sendByEmail:)];
[[UIMenuController sharedMenuController] setMenuItems: #[sendByEmailMenuItem]];
[[UIMenuController sharedMenuController] update];
Then adding its delegate
// Shared Menu item delegate actions
- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath {
self.orderAtIndex = [self.orders objectAtIndex:indexPath.row];
[self becomeFirstResponder];
return YES;
}
- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
return (action == #selector(sendByEmail:));
}
- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
if (action == #selector(sendByEmail:)) {
[self sendByEmail:sender];
}
}
// Subclassing Table View cells
-(BOOL) canPerformAction:(SEL)action withSender:(id)sender {
return (action == #selector(sendByEmail:));
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void) sendByEmail: (id) sender {
// Some actions...
}
What I am doing wrong? Any help is appreciated. Thanks

In viewWillAppear or viewDidLoad , i added these
UIMenuItem *translateToMenu = [[UIMenuItem alloc] initWithTitle:#"Translate to.." action:#selector(translateTo:)];
UIMenuController *menuController = [UIMenuController sharedMenuController];
[menuController setMenuItems:[NSArray arrayWithObject:translateToMenu]];
[menuController setMenuVisible:YES animated:YES];
added this method
-(void) translateTo: (id) sender {}
and add only these 2 methods
- (BOOL) canPerformAction:(SEL)selector withSender:(id) sender {
if (selector == #selector(translateTo:))
return YES;
else
return NO;
}
- (BOOL) canBecomeFirstResponder {
return YES;
}
Try this and let me know…

Related

Dismiss keyboard on the Textfield - Custom TableCell

I have a custom cell and in the custom cell, I have a textfield where user can able to change the value. No matter, what I tried, I cannot able to dismiss the keyboard when user enters some values. It does not hit any of the delegate methods shown below.
CheckOutTableViewCell.m
#import "CheckOutTableViewCell.h"
#implementation CheckOutTableViewCell
#synthesize productName;
#synthesize productPrice;
#synthesize productOrderNumberTF;
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
-(id) init;
{
self = [super init];
if (!self) return nil;
productOrderNumberTF.delegate = (id)self;
return self;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
// enter closes the keyboard
if ([string isEqualToString:#"\n"])
{
[textField resignFirstResponder];
return NO;
}
return YES;
}
- (void) textFieldDidEndEditing:(UITextField *)textField {
NSLog(#"%#", textField.text);
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
// dismiss keyboard when user clicks on anywhere on the UI
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.productOrderNumberTF resignFirstResponder];
}
CheckOutTableViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = #"cell";
CheckOutTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[CheckOutTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.productOrderNumberTF.delegate = (id)self;
}
return cell
}
Screenshot of the ViewController
Your delegate methods are not calling because of your textfield delegate value is not assigned.
Assign the delegate value inside the awakeFromNib
- (void)awakeFromNib {
[super awakeFromNib];
productOrderNumberTF.delegate = self;
}
The nib-loading infrastructure sends an awakeFromNib message to each object recreated from a nib archive, but only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established.

Select a textView without select text inside?

I have a UITextView inside of UITableViewCell. That UITextView I want be selectable but not text to. When the Menu Controller is appearing and i want to perform copy action, copy all text inside not just a part.
I want something like messenger app :
For the moment i have that :
Thank you in advance!
In fact it's not quite so easy, as on the road show up some strange stuff, but I managed to create a customized one.
The steps are as following:
Create a subclass of UITextView
Override canPerformAction:
withSender: for filtering the default actions of the menu
that pops up.
Configuring textView in order not to be able to edit or
select.
Editing UIMenuController items which provide the actions and buttons on the menu
Add different selectors for each UIMenuItem **** (That is because the sender of the selector is not an UIMenuItem, but a UIMenuController which leads to another matter. Check here for more info. A gist by me for that)
Code
No more talking so here is the code:
EBCustomTextView.h
//
// EBCustomTextView.h
// TestProject
//
// Created by Erid Bardhaj on 3/8/16.
// Copyright © 2016 Erid Bardhaj. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, EBCustomTextViewMenuAction) {
EBCustomTextViewMenuActionCopy,
EBCustomTextViewMenuActionDefine,
EBCustomTextViewMenuActionRead
};
#class EBCustomTextView;
#protocol EBCustomTextViewMenuActionDelegate <NSObject>
- (void)customTextView:(EBCustomTextView *)textView didSelectMenuAction:(EBCustomTextViewMenuAction)action;
#end
#interface EBCustomTextView : UITextView
#property (weak, nonatomic) id<EBCustomTextViewMenuActionDelegate> menuActionDelegate;
#end
EBCustomTextView.m
//
// EBCustomTextView.m
// TestProject
//
// Created by Erid Bardhaj on 3/8/16.
// Copyright © 2016 Erid Bardhaj. All rights reserved.
//
#import "EBCustomTextView.h"
#implementation EBCustomTextView {
EBCustomTextViewMenuAction currentAction;
}
- (void)awakeFromNib {
[super awakeFromNib];
// Configure the textView
self.editable = NO;
self.selectable = NO;
}
#pragma mark - Datasource
- (NSArray *)items {
UIMenuItem *item = [[UIMenuItem alloc] initWithTitle:#"Copy" action:#selector(copyMenuItemPressed)];
UIMenuItem *item1 = [[UIMenuItem alloc] initWithTitle:#"Define" action:#selector(defineMenuItemPressed)];
UIMenuItem *item2 = [[UIMenuItem alloc] initWithTitle:#"Read" action:#selector(readMenuItemPressed)];
return #[item, item1, item2];
}
#pragma mark - Actions
- (void)copyMenuItemPressed {
if ([self.menuActionDelegate respondsToSelector:#selector(customTextView:didSelectMenuAction:)]) {
[self.menuActionDelegate customTextView:self didSelectMenuAction:EBCustomTextViewMenuActionCopy];
}
}
- (void)defineMenuItemPressed {
if ([self.menuActionDelegate respondsToSelector:#selector(customTextView:didSelectMenuAction:)]) {
[self.menuActionDelegate customTextView:self didSelectMenuAction:EBCustomTextViewMenuActionDefine];
}
}
- (void)readMenuItemPressed {
if ([self.menuActionDelegate respondsToSelector:#selector(customTextView:didSelectMenuAction:)]) {
[self.menuActionDelegate customTextView:self didSelectMenuAction:EBCustomTextViewMenuActionRead];
}
}
#pragma mark - Private
- (void)menuItemPressedAtIndex:(NSInteger)index {
currentAction = index;
if ([self.menuActionDelegate respondsToSelector:#selector(customTextView:didSelectMenuAction:)]) {
[self.menuActionDelegate customTextView:self didSelectMenuAction:currentAction];
}
}
#pragma mark Helpers
- (void)showMenuController {
UIMenuController *theMenu = [UIMenuController sharedMenuController];
theMenu.menuItems = [self items];
[theMenu update];
CGRect selectionRect = CGRectMake (0, 0, self.contentSize.width, self.contentSize.height);
[theMenu setTargetRect:selectionRect inView:self];
[theMenu setMenuVisible:(theMenu.isMenuVisible) ? NO : YES animated:YES];
}
#pragma mark - Overridings
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// Filter any action for this textView except our custom ones
if (action == #selector(copyMenuItemPressed) || action == #selector(defineMenuItemPressed) || action == #selector(readMenuItemPressed)) {
return YES;
}
return NO;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *theTouch = [touches anyObject];
if ([theTouch tapCount] == 1 && [self becomeFirstResponder]) {
[self showMenuController];
}
}
#end
Implementation
Set your textView's class to EBCustomTextView and conform to EBCustomTextViewMenuActionDelegate
Interface
#interface ViewController () <EBCustomTextViewMenuActionDelegate>
viewDidLoad
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.textView.menuActionDelegate = self;
}
Protocol conformance
#pragma mark - Delegation
#pragma mark EBCustomTextViewMenuActionDelegate
- (void)customTextView:(EBCustomTextView *)textView didSelectMenuAction:(EBCustomTextViewMenuAction)action {
switch (action) {
case EBCustomTextViewMenuActionCopy:
NSLog(#"Copy Action");
break;
case EBCustomTextViewMenuActionRead:
NSLog(#"Read Action");
break;
case EBCustomTextViewMenuActionDefine:
NSLog(#"Define Action");
break;
default:
break;
}
}
Output
Enjoy :)
you have to use
[UITextView selectAll:self];
or (with specific range)
UITextView.selectedRange = NSMakeRange(0, 5);
or add txtview.delegate = self;
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
dispatch_async(dispatch_get_main_queue(), ^{
[textView selectAll:nil]; //nil or self as per needed
});
return YES;
}
Use UILongPressGestureRecognizer Gesture
#import "ViewController.h"
#interface ViewController ()<UIGestureRecognizerDelegate>
{
UITextView * txtV;
UILongPressGestureRecognizer * longPressGestureRecognizer;
}
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
txtV=[[UITextView alloc]initWithFrame:CGRectMake(20, 50, 280, 300)];
txtV.text = #"Jai Maharashtra";
txtV.userInteractionEnabled=YES;
txtV.selectable=NO;
txtV.editable=NO;
txtV.font= [UIFont italicSystemFontOfSize:[UIFont systemFontSize]];
[self.view addSubview:txtV];
longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:#selector(longPressGesture:)];
longPressGestureRecognizer.delegate=self;
[txtV addGestureRecognizer:longPressGestureRecognizer];
}
- (void)longPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan)
{
txtV.selectable=YES;
[txtV selectAll:self];
}
}
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
[txtV selectAll:self];
if (action == #selector(cut:))
{
return YES;
}
if (action == #selector(selectAll:))
{
return YES;
}
if (action == #selector(copy:))
{
return YES;
}
if (action == #selector(delete:))
{
return YES;
}
txtV.selectable=NO;
return YES;
}
First i start with create for every UITextView in cell a UILongPressGestureRecognizer to recognize long press.
In cellForRowAtIndexPath i just add that code :
UILongPressGestureRecognizer *recognizer1 = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:#selector(handleLongPressText1:)];
messageRecognizer.delaysTouchesBegan = YES;
UILongPressGestureRecognizer *recognizer2 = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:#selector(handleLongPressText2:)];
translateRecognizer.delaysTouchesBegan = YES;
[cell.backgroundViewText1 addGestureRecognizer:recognizer1];
[cell.backgroundViewText2 addGestureRecognizer:recognizer2];
I use two different selectors because i need to know which text to get from cell.
After the methods :
-(void)handleLongPressText1:(UILongPressGestureRecognizer *)gestureRecognizer
{
if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
CGPoint p = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p];
if (indexPath == nil){
NSLog(#"couldn't find index path");
} else {
[self becomeFirstResponder];
UIMenuController *menuController = [UIMenuController sharedMenuController];
UIMenuItem *resetMenuItem = [[UIMenuItem alloc] initWithTitle:#"Copy" action:#selector(copyMethod)];
UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:#"Read" action:#selector(readButtonAction)];
[menuController setMenuItems:[NSArray arrayWithObjects:resetMenuItem,menuItem, nil]];
CGRect rect =gestureRecognizer.view.frame;
NSLog(#"%#", NSStringFromCGRect(rect));
[menuController setTargetRect:gestureRecognizer.view.frame inView:[[gestureRecognizer view] superview]];
[menuController setMenuVisible:YES animated:YES];
}
}
}
-(void)handleLongPressText2:(UILongPressGestureRecognizer *)gestureRecognizer
{
if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
CGPoint p = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p];
if (indexPath == nil){
NSLog(#"couldn't find index path");
} else {
[self becomeFirstResponder];
UIMenuController *menuController = [UIMenuController sharedMenuController];
UIMenuItem *resetMenuItem = [[UIMenuItem alloc] initWithTitle:#"Copy" action:#selector(copyMethod)];
UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:#"Read" action:#selector(readButtonAction)];
[menuController setMenuItems:[NSArray arrayWithObjects:resetMenuItem,menuItem, nil]];
CGRect rect =gestureRecognizer.view.frame;
NSLog(#"%#", NSStringFromCGRect(rect));
[menuController setTargetRect:gestureRecognizer.view.frame inView:[[gestureRecognizer view] superview]];
[menuController setMenuVisible:YES animated:YES];
}
}
}
And for disable all default items in UIMenuController use above code
- (BOOL)canPerformAction:(SEL)iAction withSender:(id)iSender {
SEL copySelector = NSSelectorFromString(#"copyMethod");
SEL readSeletor = NSSelectorFromString(#"readButtonAction");
if (iAction == copySelector) {
return YES;
}else if (iAction ==readSeletor){
return YES;
}else{
return NO;
}
return NO;
}

Disable double tap popup UITextView

There is a popup comes when double tap on UITextView. You can see it in below image. How can we disable this?
Try this:
txtView.selectable = NO;
Edited:
Over ride this in your view controller to handle, Use this code where you have your UITextfield.
// Hide cut/copy/paste menu
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender {
UIMenuController *menuController = [UIMenuController sharedMenuController];
if (menuController) {
[UIMenuController sharedMenuController].menuVisible = NO;
}
return NO;
}
For iOS 7 & later version you need to do like this:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
}];
return [super canPerformAction:action withSender:sender];
}
Hope it will work for you.

Order of UIMenuItems in custom edit menu

I want to add my own commands to the selection menu, but also keep the standard "copy", "cut", etc. commands. I use this:
UIMenuItem *myItem = [[UIMenuItem alloc] initWithTitle:#"My Command" action:#selector(myCommand:)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObjects: myItem, nil]];
But this adds my command to the very end of the list in the edit menu. I want my command to appear first in it. How could I achieve this?
Solved it by myself. Here is what in my initWithCoder: method:
UIMenuItem *myCommandItem = [[UIMenuItem alloc] initWithTitle:#"My Command" action:#selector(myCommandPressed:)];
UIMenuItem *cutItem = [[UIMenuItem alloc] initWithTitle:#"Cut" action:#selector(myCut:)];
UIMenuItem *copyItem = [[UIMenuItem alloc] initWithTitle:#"Copy" action:#selector(myCopy:)];
UIMenuItem *pasteItem = [[UIMenuItem alloc] initWithTitle:#"Paste" action:#selector(myPaste:)];
UIMenuItem *selectItem = [[UIMenuItem alloc] initWithTitle:#"Select" action:#selector(mySelect:)];
UIMenuItem *selectAllItem = [[UIMenuItem alloc] initWithTitle:#"Select all" action:#selector(mySelectAll:)];
UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:#"Delete" action:#selector(myDelete:)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObjects: myCommandItem,
cutItem, copyItem, pasteItem, selectItem, selectAllItem, deleteItem, nil]];
Now this:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == #selector(myCommandPressed:)) {
return YES;
}
if (action == #selector(myCut:)) {
return [super canPerformAction:#selector(cut:) withSender:sender];
}
if (action == #selector(myCopy:)) {
return [super canPerformAction:#selector(copy:) withSender:sender];
}
if (action == #selector(myPaste:)) {
return [super canPerformAction:#selector(paste:) withSender:sender];
}
if (action == #selector(mySelect:)) {
return [super canPerformAction:#selector(select:) withSender:sender];
}
if (action == #selector(mySelectAll:)) {
return [super canPerformAction:#selector(selectAll:) withSender:sender];
}
if (action == #selector(myDelete:)) {
return [super canPerformAction:#selector(delete:) withSender:sender];
}
return NO;
}
And finally:
- (void) myCommandPressed: (id) sender {
NSLog(#"My Command pressed");
}
- (void) myCut: (id) sender {
[self cut:sender];
}
- (void) myCopy: (id) sender {
[self copy:sender];
}
- (void) myPaste: (id) sender {
[self paste:sender];
}
- (void) mySelect: (id) sender {
[self select:sender];
}
- (void) mySelectAll: (id) sender {
[self selectAll:sender];
}
- (void) myDelete: (id) sender {
[self delete:sender];
}

uisearchbar doesn't work

I created a subClass of UITextView with a searchBar, here is the code:
#import "SezioniTableController.h"
#interface SezioniTableController ()
#end
#implementation SezioniTableController
#synthesize searchBar,searchDisplayController;
#synthesize arraySezioni,arrayFiltrato;
#synthesize objTesto;
- (id)initWithStyle:(UITableViewStyle)style andArray:(NSMutableArray *)array{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
self.searchBar.delegate = self;
self.searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
self.searchDisplayController.delegate = self;
self.searchDisplayController.searchResultsDataSource = self;
self.arraySezioni = array;
self.arrayFiltrato = array;
}
return self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void) loadView {}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return self.arrayFiltrato.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"MyIdentifier"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewStylePlain reuseIdentifier:#"MyIdentifier"];
}
self.objTesto = [arrayFiltrato objectAtIndex:indexPath.row];
cell.textLabel.text = self.objTesto.titoloTesto;
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:#"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
*/
NSDictionary *dict = [NSDictionary dictionaryWithObject:[self.arrayFiltrato objectAtIndex:indexPath.row] forKey:#"Testo"];
[[NSNotificationCenter defaultCenter] postNotificationName:#"PassaggioTesto" object:self userInfo:dict];
NSLog(#"Click");
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return self.searchBar; //in .h, IBOutlet UISearchBar* search;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 44;
}
- (BOOL) searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString{
[self filterContentForSearchText:searchString scope: [[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
NSLog(#"aa");
//[[NSNotificationCenter defaultCenter] postNotificationName:#"ReloadTable" object:self];
// Return YES to cause the search result table view to be reloaded.
return YES;
}
- (BOOL) searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption{
[self filterContentForSearchText:[self.searchDisplayController.searchBar text] scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:searchOption]];
NSLog(#"ab");
//[[NSNotificationCenter defaultCenter] postNotificationName:#"ReloadTable" object:self];
// Return YES to cause the search result table view to be reloaded.
return YES;
}
- (void) filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope{
NSLog(#"a count:%d",self.arraySezioni.count);
[self.arrayFiltrato removeAllObjects]; // First clear the filtered array.
for (objTesto in self.arraySezioni){
NSComparisonResult result = [objTesto.titoloTesto compare:searchText options:NSCaseInsensitiveSearch range:NSMakeRange(0, [searchText length])];
if (result == NSOrderedSame){
NSLog(#"Titolo: %#",objTesto.titoloTesto);
[self.arrayFiltrato addObject:self.objTesto];
}else{
NSLog(#"Non trovato");
}
}
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)saearchBar {
[self.arrayFiltrato removeAllObjects];
[self.arrayFiltrato addObjectsFromArray: self.arraySezioni];
}
#end
On my uiviewcontroller I create a table using the uitableview created with this code:
self.arrayTesti = [self.dataLoad leggiArgomentiDellaSezione:tag];
self.table = [[SezioniTableController alloc] initWithStyle:UITableViewStylePlain andArray:self.arrayTesti];
self.tableArgumentView.delegate = self.table;
self.tableArgumentView.dataSource = self.table;
[self.tableArgumentView reloadData];
The viewcontroller is for an iPad application, the table works perfectly but if I try to search something it doesn't work!
Can you help me?
If you assign
self.arraySezioni = array;
self.arrayFiltrato = array;
then both self.arraySezioni and self.arrayFiltrato are pointers to the same array. Which means that if you empty one array with
[self.arrayFiltrato removeAllObjects];
then the other array self.arraySezioni (and the original array) are also empty.
So at least self.arrayFiltrato should be a copy of the original array:
self.arrayFiltrato = [array copy];

Resources