uiactionsheet


unrecognized selector sent to instance UIActionSheet


I receive the following error when trying to show an ActionSheet...
2012-11-16 04:07:03.878 MKS WebTech[814:c07] -[mksWorkOrderViewController _presentActionSheet:asPopoverFromBarButtonItem:orFromRect:inView:withPreferredArrowDirections:passthroughViews:backgroundStyle:animated:]: unrecognized selector sent to instance 0x75a5950
- (IBAction)ActionClick:(id)sender {
popupSheet = [[UIActionSheet alloc] init];
[popupSheet setDelegate:self];
[popupSheet addButtonWithTitle:#"Contact List"];
[popupSheet addButtonWithTitle:#"Zone Descriptions"];
[popupSheet addButtonWithTitle:#"Zone Testing"];
[popupSheet addButtonWithTitle:#"Panels"];
[popupSheet addButtonWithTitle:#"Time Sheet"];
[popupSheet addButtonWithTitle:#"Inventory"];
[popupSheet addButtonWithTitle:#"Other Appt."];
[popupSheet addButtonWithTitle:#"Alarm History"];
[popupSheet addButtonWithTitle:#"Service History"];
[popupSheet addButtonWithTitle:#"Complete"];
[popupSheet addButtonWithTitle:#"Cancel"];
[popupSheet setCancelButtonIndex:10];
// Prepare your action sheet
[popupSheet showFromBarButtonItem:bntAction animated:NO];
[popupSheet release];
}
The error happen "showFromBarButtonItem:bntAction" I also tried with sender but same result
also the canPerformAction fires with no problem...
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
return YES;
}
I had this problem once, it's not the same case, but for me, this worked:
Go to Interface Builder
Check ALL objects, the problem for me was that I connected an object to a variable that I later deleted, so it didn't exist.
Conclusion: I had connected an object to a variable that doesn't exist.
Otherwise, the code looks fine :)
For anyone else who runs into this in the future (as I just did): the problem is that UIActionSheet walks up the responder chain calling -canPerformAction:#selector(_presentActionSheet:asPopover... etc etc) on each.
So since the controller incorrectly responds YES, the UIActionSheet goes ahead and tries to call that method, an implementation doesn't exist, and you hit the error.
The correct fix is to reimplement your -canPerformAction:withSender: to only return YES to things you actually handle.

Related Links

Attachment action sheet hidden behind keyboard in iOS 9
Use of Actionsheet in Ionic 2
Disable WKActionSheet on WKWebView
Action sheet programatically [closed]
unrecognized selector sent to instance UIActionSheet
Using Viewcontroller to control tabbarController
ShareKit 2.0: how to add a custom NON-SHARE item in action sheet?
Fire UIActionSheet in ViewDidLoad first load only
Setting bounds for UIActionSheet?

Categories

HOME
go
eclipse
gridview
localization
codenvy
apache-flink
flex
solaris
owl-carousel
pdfbox
bitbucket-api
tivoli
cq5
data-visualization
flume
owin
ibeacon-android
startup
datastage
naivebayes
plink
eip
microsoft-dynamics-nav
smartclient
jmp
simpleitk
microsoft-ocr
mongoid6
aggregation
epsilon
displaytag
google-api-client
expressionengine3
definitelytyped
bulletphysics
datastax-enterprise-graph
google-earth
weather
hibernate-validator
mnist
mongoose-schema
dbnull
movilizer
install.packages
apollostack
memory-mapping
vaadin-charts
jide
nanoc
dtsearch
manova
google-cse
aquamacs
amq
excel-dna
avx
mouseleave
cvxpy
change-tracking
actor-platform
qtplugin
tinkerpop3
drawstring
dup
xdoclet
tracker-enabled-dbcontext
cda
database-relations
realsense
jbase
assertion
phonertc
rubaxa-sortable
dock
cgi-bin
visual-sourcesafe-2005
eoferror
airbrake
entity-framework-4.3
cryptographichashfunction
sip-server
universal-image-loader
kissfft
maven-scm
koala
jammer
scringo
epiceditor
wp7test
idn
extreme-programming
monotouch.dialog
database-create
httponly
facebook-iframe
vs-android
maven-1
nstokenfield
lalr
business-model
ifilter
idatareader

Resources

Encrypt Message