ios


iOS:Subclassing UIPickerView not loading in the main view


I'm trying to subclass UIPickerView but is not loading in the main view.
Here is my code:
//Picker.h:
#interface Picker : UIPickerView
- (id)initWithFrame:(CGRect)frame;
//Picker.m:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return 3;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return #"bla";
}
This the code on my viewController:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:YES];
self.myPicker = [[Picker alloc] initWithFrame:self.view.frame];
[self.view addSubview:_myPicker];
}
Any of you knows why the picker is not loading on my view?
I'll really appreciate your help.
First, add <UIPickerViewDelegate, UIPickerViewDataSource> in header of Picker.h.
Then, assign delegate to your own Picker object.
-(id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.delegate = self; // <-- add this line
}
return self;
}

Related Links

Selecting a word and shows tooltip in iOS
UIBarButtonIteem common to all controllers
App ID Prefix at apple developer
What happens if I use accessibilityIdentifier and accessibilityLabel on same element
Migrating my app to 64 bit with parse and I get this link error that is driving me crazy
Calculating distance between two PFGeoPoints in Swift
Why isn't func motionEnded not working in GameScene?
moving UINavigationBar frame causes unrecognizable clicks
Why is (form.$error && form.$submitted) true on start?
How to keep objects in NSMutableArray?
Parse::UserCannotBeAlteredWithoutSessionError 206 iOS
iOS - How to Control the Kind of Animation in an Unwind Segue?
Flurry Ads Not Showing Up
UICollectionview cellForItemAtIndexPath not getting called when reload in iOS 8
Subviews in UITableViewCell's containView are not added into the UI hierarchy in iOS9
Why would sqlite3 fail to set cache_size?

Categories

HOME
lsf
common-lisp
clojure
simulated-annealing
web-services
serial-port
order
windows-runtime
libreoffice
jqgrid
openvpn
http2
dbus
command-line-arguments
libssh
curve-fitting
jscodeshift
burp
structure
desire2learn
scalability
c++builder-5
buffer-overflow
whatsapi
charts.js
magento2.0.2
nest-thermostat
gosublime
double-click-advertising
draggable
nio
msal
jetty-9
cookiestore
jsonstore
internet-explorer-10
nomenclature
qmake
mrtg
orchestrate
ternary
infiniband
assembly-references
mysql-error-1050
sizing
setwindowshookex
xceed
post-increment
ellipsis
webclient-download
mars
highslide
parsoid
multer
samsung-gear
materialdrawer
thinktecture-ident-server
coldfusion-10
movie
reactive-cocoa-3
applicationstate
information-schema
cellular-automata
azimuth
dotliquid
css3pie
sonata-media-bundle
blazeds
pdf-scraping
sqlprofiler
jquery-mobile-popup
pligg
nsusernotificationcenter
webcal
scrollpane
dependency-walker
working-directory
google-profiles-api
molehill
server.mappath
magento-1.5
textboxlist
nntp
formsauthentication
machine.config
apache-config
indextank
utility
non-relational-database
development-machine
stsadm

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App