1- //
1+ //
22// Copyright 2011 ESCOZ Inc - http://escoz.com
3- //
4- // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5- // file except in compliance with the License. You may obtain a copy of the License at
6- //
7- // http://www.apache.org/licenses/LICENSE-2.0
8- //
3+ //
4+ // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5+ // file except in compliance with the License. You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
99// Unless required by applicable law or agreed to in writing, software distributed under
10- // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10+ // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
1111// ANY KIND, either express or implied. See the License for the specific language governing
1212// permissions and limitations under the License.
1313//
@@ -59,14 +59,14 @@ - (QElement *)initWithKey:(NSString *)key {
5959
6060- (UITableViewCell *)getCellForTableView : (QuickDialogTableView *)tableView controller : (QuickDialogController *)controller {
6161 _controller = controller;
62-
62+
6363 QTableViewCell *cell= [self getOrCreateEmptyCell: tableView];
6464
6565 [cell applyAppearanceForElement: self ];
6666
67- cell.textLabel .text = nil ;
68- cell.detailTextLabel .text = nil ;
69- cell.imageView .image = nil ;
67+ cell.textLabel .text = nil ;
68+ cell.detailTextLabel .text = nil ;
69+ cell.imageView .image = nil ;
7070 cell.selectionStyle = UITableViewCellSelectionStyleNone;
7171 cell.showsReorderControl = YES ;
7272 cell.accessoryView = nil ;
@@ -82,17 +82,29 @@ - (QTableViewCell *)getOrCreateEmptyCell:(QuickDialogTableView *)tableView {
8282 return cell;
8383}
8484
85+ - (void )handleElementSelected : (QuickDialogController *)controller {
86+ if (_onSelected!= nil )
87+ _onSelected ();
8588
89+ if (self.controllerAction !=NULL && !controller.quickDialogTableView .editing ){
90+ SEL selector = NSSelectorFromString (self.controllerAction );
91+ if ([controller respondsToSelector: selector]) {
92+ [(id )controller performSelector: selector withObject: controller];
93+ } else {
94+ NSLog (@" No method '%@ ' was found on controller %@ " , self.controllerAction , [controller class ]);
95+ }
96+ }
97+ }
8698
8799- (void )selectedAccessory : (QuickDialogTableView *)tableView controller : (QuickDialogController *)controller indexPath : (NSIndexPath *)indexPath {
88100 if (self.controllerAccessoryAction !=NULL ){
89- SEL selector = NSSelectorFromString (self.controllerAccessoryAction );
90- if ([controller respondsToSelector: selector]) {
91- ((void (*)(id , SEL , id )) objc_msgSend)(controller, selector, self);
92- } else {
93- NSLog (@" No method '%@ ' was found on controller %@ " , self.controllerAccessoryAction , [controller class ]);
94- }
101+ SEL selector = NSSelectorFromString (self.controllerAccessoryAction );
102+ if ([controller respondsToSelector: selector]) {
103+ [(id )controller performSelector: selector withObject: controller];
104+ } else {
105+ NSLog (@" No method '%@ ' was found on controller %@ " , self.controllerAccessoryAction , [controller class ]);
95106 }
107+ }
96108}
97109
98110- (void )selected : (QuickDialogTableView *)tableView controller : (QuickDialogController *)controller indexPath : (NSIndexPath *)indexPath {
@@ -144,7 +156,7 @@ - (void)performAction
144156 if (self.controllerAction !=NULL ){
145157 SEL selector = NSSelectorFromString (self.controllerAction );
146158 if ([_controller respondsToSelector: selector]) {
147- ((void (*)(id , SEL , id )) objc_msgSend)(_controller, selector, self);
159+ ((void (*)(id , SEL , id )) objc_msgSend)(_controller, selector, self);
148160 } else {
149161 NSLog (@" No method '%@ ' was found on controller %@ " , self.controllerAction , [_controller class ]);
150162 }
0 commit comments