iOS Multiple UIPickerView Only Showing 1 view -
iOS Multiple UIPickerView Only Showing 1 view -
i have 1 viewcontroller 5 uipickerview in. thought when each select button pressed pickerview called , separate button shows result picked. problem have no matter button selected , uipickerview chosen button changes final one. uipickerview showing final until press lastly button , shows 1st , lastly uipickerview @ same time.
update
code
#import <uikit/uikit.h> #import <messageui/messageui.h> #import <messageui/mfmailcomposeviewcontroller.h> #import <corelocation/corelocation.h> @interface viewcontroller : uiviewcontroller <mfmailcomposeviewcontrollerdelegate, uipickerviewdatasource,uipickerviewdelegate>{ uitextfield *nametextfield; uitextfield *emailtextfield; uitextfield *datetextfield; uitextfield *timetextfield; uitextfield *blanktextfield; uitextfield *blankbtextfield; uitextview *messagetextview; uipickerview *categorytypepicker; uipickerview *locationtypepicker; uipickerview *originatortypepicker; uipickerview *destinationtypepicker; uipickerview *statustypepicker; uibutton *categorytypebtn; uibutton *locationtypebtn; uibutton *originatortypebtn; uibutton *destinationtypebtn; uibutton *statustypebtn; nsarray *categorytypes; nsarray *locationtypes; nsarray *originatortypes; nsarray *destinationtypes; nsarray *statustypes; cllocationmanager *locationmanager; iboutlet uilabel *mlabelcategory; nsmutablearray *arraynocategory; iboutlet uipickerview *pickerviewcategory; mfmailcomposeviewcontroller *email; } @property (nonatomic, retain) mfmailcomposeviewcontroller *email; @property(nonatomic,retain) iboutlet uitextfield *nametextfield; @property(nonatomic,retain) iboutlet uitextfield *emailtextfield; @property(nonatomic,retain) iboutlet uitextfield *datetextfield; @property(nonatomic,retain) iboutlet uitextfield *timetextfield; @property(nonatomic,retain) iboutlet uitextfield *blanktextfield; @property(nonatomic,retain) iboutlet uitextfield *blankbtextfield; @property(nonatomic,retain) iboutlet uilabel *mlabelcategory; @property(nonatomic,retain) iboutlet uitextview *messagetextview; @property(nonatomic,retain) iboutlet uipickerview *categorytypepicker; @property(nonatomic,retain) iboutlet uipickerview *locationtypepicker; @property(nonatomic,retain) iboutlet uipickerview *originatortypepicker; @property(nonatomic,retain) iboutlet uipickerview *destinationtypepicker; @property(nonatomic,retain) iboutlet uipickerview *statustypepicker; @property(nonatomic,retain) iboutlet uibutton *categorytypebtn; @property(nonatomic,retain) iboutlet uibutton *locationtypebtn; @property(nonatomic,retain) iboutlet uibutton *originatortypebtn; @property(nonatomic,retain) iboutlet uibutton *destinationtypebtn; @property(nonatomic,retain) iboutlet uibutton *statustypebtn; @property(nonatomic,retain) nsarray *categorytypes; @property(nonatomic,retain) nsarray *locationtypes; @property(nonatomic,retain) nsarray *originatortypes; @property(nonatomic,retain) nsarray *destinationtypes; @property(nonatomic,retain) nsarray *statustypes; @property nsstring *name; @property nsstring *emailaddress; @property nsstring *date; @property nsstring *time; @property nsstring *blank; @property nsstring *blankb; @property nsstring *category; @property nsstring *message; - (ibaction)checkdata:(id)sender; - (ibaction)backgroundtap:(id)sender; - (ibaction)donebuttonpressed:(id)sender; -(ibaction) showcategorytypepicker; -(ibaction) showlocationtypepicker; -(ibaction) showoriginatortypepicker; -(ibaction) showdestinationtypepicker; -(ibaction) showstatustypepicker; - (void)sendmail; @end
.m code
#import "viewcontroller.h" #import <messageui/messageui.h> #import <messageui/mfmailcomposeviewcontroller.h> #define geolocation true // false no latitude/longitude info #define kpickercolumn 1 typedef ns_enum(nsinteger, pickertype) { category_picker, location_picker, originator_picker, destination_picker, status_picker }; #define kpickercolumn 1 #define kpicker_tag 101 @interface viewcontroller () @end @implementation viewcontroller { uipickerview *picker; pickertype pickertype; } @synthesize nametextfield, emailtextfield, datetextfield, timetextfield, blanktextfield, blankbtextfield, mlabelcategory, messagetextview, categorytypes, locationtypes, originatortypes, destinationtypes, statustypes; @synthesize name, emailaddress, date, time, blank, blankb, category, message, email, categorytypebtn, locationtypebtn, originatortypebtn, destinationtypebtn, statustypebtn; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization categorytypes = [[nsarray alloc] initwithobjects:@"appetizers",@"breakfast",@"dessert",@"drinks", @"main dish/entree", @"salad", @"side dish", @"soup", @"snack", @"baby food", @"pet food",nil]; locationtypes = [[nsarray alloc] initwithobjects:@"african",@"american",@"armenian",@"barbecue" ,nil]; originatortypes = [[nsarray alloc] initwithobjects:@"african",@"american",@"armenian",@"barbecue", nil]; destinationtypes = [[nsarray alloc] initwithobjects:@"african",@"american",@"armenian",@"barbecue", nil]; statustypes = [[nsarray alloc] initwithobjects:@"african",@"american",@"armenian",@"barbecue", nil]; } homecoming self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. nametextfield.text = nil; emailtextfield.text = nil; datetextfield.text = nil; timetextfield.text = nil; blanktextfield.text = nil; blankbtextfield.text = nil; mlabelcategory.text = nil; messagetextview.text = nil; picker = [[uipickerview alloc] initwithframe:cgrectmake(100,100,400,160)]; picker.showsselectionindicator = true; picker.datasource = self; picker.delegate = self; picker.hidden = yes; [self.view addsubview:picker]; } /* // override allow orientations other default portrait orientation. - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { // homecoming yes supported orientations. homecoming (interfaceorientation == uiinterfaceorientationportrait); } */ - (void)touchesbegan:(nsset *)touches withevent:(uievent *)eve { picker.hidden = yes; } #pragma mark - #pragma mark picker methods - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview { homecoming kpickercolumn; } - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component { switch (pickertype) { case category_picker: homecoming [categorytypes count];; break; case location_picker: homecoming [locationtypes count]; break; case originator_picker: homecoming [originatortypes count]; break; case destination_picker: homecoming [destinationtypes count]; break; case status_picker: homecoming [statustypes count]; break; default: homecoming -1; break; } } - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { switch (pickertype) { case category_picker: homecoming [categorytypes objectatindex:row]; break; case location_picker: homecoming [locationtypes objectatindex:row]; break; case originator_picker: homecoming [originatortypes objectatindex:row]; break; case destination_picker: homecoming [destinationtypes objectatindex:row]; break; case status_picker: homecoming [statustypes objectatindex:row]; break; default: homecoming nil; break; } } - (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { switch (pickertype) { case category_picker: { nsstring *categorytype = [categorytypes objectatindex:[pickerview selectedrowincomponent:0]]; [categorytypebtn settitle:categorytype forstate:uicontrolstatenormal]; break; } case location_picker: { nsstring *locationtype = [locationtypes objectatindex:[pickerview selectedrowincomponent:0]]; [locationtypebtn settitle:locationtype forstate:uicontrolstatenormal]; break; } case originator_picker: { nsstring *originatortype = [originatortypes objectatindex:[pickerview selectedrowincomponent:0]]; [originatortypebtn settitle:originatortype forstate:uicontrolstatenormal]; break; } case destination_picker: { nsstring *destinationtype = [destinationtypes objectatindex:[pickerview selectedrowincomponent:0]]; [destinationtypebtn settitle:destinationtype forstate:uicontrolstatenormal]; break; } case status_picker:{ nsstring *statustype = [statustypes objectatindex:[pickerview selectedrowincomponent:0]]; [statustypebtn settitle:statustype forstate:uicontrolstatenormal]; break; } default: break; } } -(ibaction) showlocationtypepicker{ pickertype = location_picker; picker.hidden = no; [picker reloadallcomponents]; } -(ibaction) showcategorytypepicker{ pickertype = category_picker; picker.hidden = no; [picker reloadallcomponents]; } -(ibaction) showoriginatortypepicker{ pickertype = originator_picker; picker.hidden = no; [picker reloadallcomponents]; } -(ibaction) showdestinationtypepicker{ pickertype = destination_picker; picker.hidden = no; [picker reloadallcomponents]; } -(ibaction) showstatustypepicker{ pickertype = status_picker; picker.hidden = no; [picker reloadallcomponents]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (nsuinteger)supportedinterfaceorientations { homecoming uiinterfaceorientationmaskportrait; } #pragma - getting info ui //nsstring *test = nil; - (ibaction)checkdata:(id)sender { /* name = nametextfield.text; surname = surnametextfield.text; borndate = borndatetextfield.text; address = addresstextfield.text; zipcode = ziptextfield.text; email = emailtextfield.text; */ //nslog(@" name: %@ \n surname: %@ \n date of birth: %@ \n address: %@ \n post code: %@ \n email: %@ \n", name, surname, borndate, address, zipcode, email); unsigned int x,a = 0; nsmutablestring *emailmessage; //stringa variabile emailmessage = [nsmutablestring stringwithformat: @""]; //le stringhe mutabili vanno inizializzate in questo modo! (x=0; x<7; x++) { switch (x) { case 0: if (nametextfield.text == nil) { [emailmessage appendstring:@"name, "]; a=1; } break; case 1: if (emailtextfield.text == nil) { [emailmessage appendstring:@"email address, "]; a=1; } break; case 2: if (datetextfield.text == nil) { [emailmessage appendstring:@"date of near miss, "]; a=1; } break; case 3: if (timetextfield.text == nil) { [emailmessage appendstring:@"time of near miss, "]; a=1; } break; case 4: if (blanktextfield.text == nil) { [emailmessage appendstring:@"post code, "]; a=1; } break; case 5: if (blankbtextfield.text == nil) { [emailmessage appendstring:@"email, "]; a=1; } break; case 6: if (mlabelcategory.text == nil) { [emailmessage appendstring:@"category, "]; a=1; } break; case 7: if (messagetextview.text == nil) { [emailmessage appendstring:@"observation description, "]; a=1; } break; default: break; } } { name = nametextfield.text; emailaddress = emailtextfield.text; date = datetextfield.text; time = timetextfield.text; blank = blanktextfield.text; blankb = blankbtextfield.text; category = mlabelcategory.text; message = messagetextview.text; nsmutablestring *nearmissreport; nearmissreport = [nsmutablestring stringwithformat: @"<br><br> <b>name:</b> %@ <br> <b>email address:</b> %@ <br> <b>date of near miss:</b> %@ <br> <b>time of near miss:</b> %@ <br> <b>post code:</b> %@ <br> <b>email address:</b> %@ <br> <b>category:</b> %@ <br><b>observation description:</b> %@ <br>", name, emailaddress, date, time, blank, blankb, category, message]; nslog(@"near miss report: %@", nearmissreport); nsmutablestring *testomail; testomail = [nsmutablestring stringwithformat: nearmissreport]; nslog(@"%@", testomail); //mfmailcomposeviewcontroller *picker = [[mfmailcomposeviewcontroller alloc] init]; mfmailcomposeviewcontroller *pv = [[mfmailcomposeviewcontroller alloc] init]; pv.mailcomposedelegate = self; [pv setsubject: name]; // set recipients. nsarray *torecipients = [nsarray arraywithobjects:@"paul.haddell@bbmmjv.com",nil]; //nsarray *ccrecipients = [nsarray arraywithobjects:@"second@example.com",@"third@example.com", nil]; //nsarray *bccrecipients = [nsarray arraywithobjects:@"four@example.com",nil]; [pv settorecipients:torecipients]; //[picker setccrecipients:ccrecipients]; //[picker setbccrecipients:bccrecipients]; // attach image email. nsstring *path = [[nsbundle mainbundle] pathforresource:@"" oftype:@"png"]; nsdata *mydata = [nsdata datawithcontentsoffile:path]; [pv addattachmentdata:mydata mimetype:@"image/png" filename:@""]; // fill out email body text. //nsmutablestring *emailbody; testomail = [nsmutablestring stringwithformat: @"%@", testomail]; [pv setmessagebody:testomail ishtml:yes]; //html!!!!!! // nowadays mail service composition interface. [self presentviewcontroller:pv animated:yes completion:nil]; } } // mail service compose view controller delegate method - (void)mailcomposecontroller:(mfmailcomposeviewcontroller *)controller didfinishwithresult:(mfmailcomposeresult)result error:(nserror *)error { [self dismissmodalviewcontrolleranimated:yes]; } #pragma mark - mandare email /* - (void)sendmail:(nsmutablestring*)testomail{ mfmailcomposeviewcontroller *picker = [[mfmailcomposeviewcontroller alloc] init]; picker.mailcomposedelegate = self; [picker setsubject:@"reclutamento pompieri"]; // set recipients. nsarray *torecipients = [nsarray arraywithobjects:@"reda.bousbah@gmail.com",nil]; //nsarray *ccrecipients = [nsarray arraywithobjects:@"second@example.com",@"third@example.com", nil]; //nsarray *bccrecipients = [nsarray arraywithobjects:@"four@example.com",nil]; [picker settorecipients:torecipients]; //[picker setccrecipients:ccrecipients]; //[picker setbccrecipients:bccrecipients]; // attach image email. //nsstring *path = [[nsbundle mainbundle] pathforresource:@"ipodnano" oftype:@"png"]; //nsdata *mydata = [nsdata datawithcontentsoffile:path]; //[picker addattachmentdata:mydata mimetype:@"image/png" filename:@"ipodnano"]; // fill out email body text. nsstring *emailbody = @"it raining in sunny california!"; [picker setmessagebody:emailbody ishtml:no]; // nowadays mail service composition interface. [self presentviewcontroller:picker animated:yes completion:nil]; } */ #pragma mark - methods command keyboard - (ibaction)backgroundtap:(id)sender //method resign keyboard when background tapped { [nametextfield resignfirstresponder]; [emailtextfield resignfirstresponder]; [datetextfield resignfirstresponder]; [timetextfield resignfirstresponder]; [blanktextfield resignfirstresponder]; [blankbtextfield resignfirstresponder]; [mlabelcategory resignfirstresponder]; [messagetextview resignfirstresponder]; } - (ibaction)donebuttonpressed:(id)sender { nslog( @"done button pressed"); [sender resignfirstresponder]; } @end
you can this. example, have create changes create work app
#import "viewcontroller.h" #import <messageui/messageui.h> #import <messageui/mfmailcomposeviewcontroller.h> #define geolocation true // false no latitude/longitude info #define kpickercolumn 1 typedef ns_enum(nsinteger, pickertype) { category_picker, location_picker, originator_picker, destination_picker, status_picker }; #define kpickercolumn 1 #define kpicker_tag 101 @interface viewcontroller () @end @implementation viewcontroller { uipickerview *picker; pickertype pickertype; } @synthesize nametextfield, emailtextfield, datetextfield, timetextfield, blanktextfield, blankbtextfield, mlabelcategory, messagetextview; @synthesize name, emailaddress, date, time, blank, blankb, category, message, email; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization categorytypes = [[nsarray alloc] initwithobjects:@"appetizers",@"breakfast",@"dessert",@"drinks", @"main dish/entree", @"salad", @"side dish", @"soup", @"snack", @"baby food", @"pet food",nil]; locationtypes = [[nsarray alloc] initwithobjects:@"african",@"american",@"armenian",@"barbecue" ,nil]; originatortypes = [[nsarray alloc] initwithobjects:@"african",@"american",@"armenian",@"barbecue", nil]; destinationtypes = [[nsarray alloc] initwithobjects:@"african",@"american",@"armenian",@"barbecue", nil]; statustypes = [[nsarray alloc] initwithobjects:@"african",@"american",@"armenian",@"barbecue", nil]; } homecoming self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. nametextfield.text = nil; emailtextfield.text = nil; datetextfield.text = nil; timetextfield.text = nil; blanktextfield.text = nil; blankbtextfield.text = nil; mlabelcategory.text = nil; messagetextview.text = nil; picker = [[uipickerview alloc] initwithframe:cgrectmake(100,100,400,160)]; picker.showsselectionindicator = true; picker.datasource = self; picker.delegate = self; picker.hidden = yes; [self.view addsubview:picker]; } /* // override allow orientations other default portrait orientation. - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { // homecoming yes supported orientations. homecoming (interfaceorientation == uiinterfaceorientationportrait); } */ - (void)touchesbegan:(nsset *)touches withevent:(uievent *)eve { picker.hidden = yes; } #pragma mark - #pragma mark picker methods - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview { homecoming kpickercolumn; } - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component { switch (pickertype) { case category_picker: homecoming [categorytypes count];; break; case location_picker: homecoming [locationtypes count]; break; case originator_picker: homecoming [originatortypes count]; break; case destination_picker: homecoming [destinationtypes count]; break; case status_picker: homecoming [statustypes count]; break; default: homecoming -1; break; } } - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { switch (pickertype) { case category_picker: homecoming [categorytypes objectatindex:row]; break; case location_picker: homecoming [locationtypes objectatindex:row]; break; case originator_picker: homecoming [originatortypes objectatindex:row]; break; case destination_picker: homecoming [destinationtypes objectatindex:row]; break; case status_picker: homecoming [statustypes objectatindex:row]; break; default: homecoming nil; break; } } - (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { switch (pickertype) { case category_picker: { nsstring *categorytype = [categorytypes objectatindex:[pickerview selectedrowincomponent:0]]; [categorytypebtn settitle:categorytype forstate:uicontrolstatenormal]; break; } case location_picker: { nsstring *locationtype = [locationtypes objectatindex:[pickerview selectedrowincomponent:0]]; [locationtypebtn settitle:locationtype forstate:uicontrolstatenormal]; break; } case originator_picker: { nsstring *originatortype = [originatortypes objectatindex:[pickerview selectedrowincomponent:0]]; [originatortypebtn settitle:originatortype forstate:uicontrolstatenormal]; break; } case destination_picker: { nsstring *destinationtype = [destinationtypes objectatindex:[pickerview selectedrowincomponent:0]]; [destinationtypebtn settitle:destinationtype forstate:uicontrolstatenormal]; break; } case status_picker:{ nsstring *statustype = [statustypes objectatindex:[pickerview selectedrowincomponent:0]]; [statustypebtn settitle:statustype forstate:uicontrolstatenormal]; break; } default: break; } } -(ibaction) showlocationtypepicker{ pickertype = location_picker; picker.hidden = no; [picker reloadallcomponents]; } -(ibaction) showcategorytypepicker{ pickertype = category_picker; picker.hidden = no; [picker reloadallcomponents]; } -(ibaction) showoriginatortypepicker{ pickertype = originator_picker; picker.hidden = no; [picker reloadallcomponents]; } -(ibaction) showdestinationtypepicker{ pickertype = destination_picker; picker.hidden = no; [picker reloadallcomponents]; } -(ibaction) showstatustypepicker{ pickertype = status_picker; picker.hidden = no; [picker reloadallcomponents]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (nsuinteger)supportedinterfaceorientations { homecoming uiinterfaceorientationmaskportrait; } #pragma - getting info ui //nsstring *test = nil; - (ibaction)checkdata:(id)sender { /* name = nametextfield.text; surname = surnametextfield.text; borndate = borndatetextfield.text; address = addresstextfield.text; zipcode = ziptextfield.text; email = emailtextfield.text; */ //nslog(@" name: %@ \n surname: %@ \n date of birth: %@ \n address: %@ \n post code: %@ \n email: %@ \n", name, surname, borndate, address, zipcode, email); unsigned int x,a = 0; nsmutablestring *emailmessage; //stringa variabile emailmessage = [nsmutablestring stringwithformat: @""]; //le stringhe mutabili vanno inizializzate in questo modo! (x=0; x<7; x++) { switch (x) { case 0: if (nametextfield.text == nil) { [emailmessage appendstring:@"name, "]; a=1; } break; case 1: if (emailtextfield.text == nil) { [emailmessage appendstring:@"email address, "]; a=1; } break; case 2: if (datetextfield.text == nil) { [emailmessage appendstring:@"date of near miss, "]; a=1; } break; case 3: if (timetextfield.text == nil) { [emailmessage appendstring:@"time of near miss, "]; a=1; } break; case 4: if (blanktextfield.text == nil) { [emailmessage appendstring:@"post code, "]; a=1; } break; case 5: if (blankbtextfield.text == nil) { [emailmessage appendstring:@"email, "]; a=1; } break; case 6: if (mlabelcategory.text == nil) { [emailmessage appendstring:@"category, "]; a=1; } break; case 7: if (messagetextview.text == nil) { [emailmessage appendstring:@"observation description, "]; a=1; } break; default: break; } } nslog (@"email message: %@", emailmessage); if (a == 1) { nsmutablestring *popuperror; popuperror = [nsmutablestring stringwithformat: @"per inviare compilare seguenti campi: "]; [popuperror appendstring:emailmessage]; //aggiungo miei errori [popuperror appendstring: @" grazie della comprensione."]; // nslog(@"%@", popuperror); uialertview *chiamataeffettuata = [[uialertview alloc] initwithtitle:@"attention" //titolo del mio foglio message:popuperror delegate:self cancelbuttontitle:@"ok, correggo" //bottone con cui si chiude il messaggio otherbuttontitles:nil, nil]; [chiamataeffettuata show]; //istanza per mostrare effettivamente il messaggio } else { name = nametextfield.text; emailaddress = emailtextfield.text; date = datetextfield.text; time = timetextfield.text; blank = blanktextfield.text; blankb = blankbtextfield.text; category = mlabelcategory.text; message = messagetextview.text; nsmutablestring *nearmissreport; nearmissreport = [nsmutablestring stringwithformat: @"<br><br> <b>name:</b> %@ <br> <b>email address:</b> %@ <br> <b>date of near miss:</b> %@ <br> <b>time of near miss:</b> %@ <br> <b>post code:</b> %@ <br> <b>email address:</b> %@ <br> <b>category:</b> %@ <br><b>observation description:</b> %@ <br>", name, emailaddress, date, time, blank, blankb, category, message]; nslog(@"near miss report: %@", nearmissreport); nsmutablestring *testomail; testomail = [nsmutablestring stringwithformat: nearmissreport]; nslog(@"%@", testomail); //mfmailcomposeviewcontroller *picker = [[mfmailcomposeviewcontroller alloc] init]; mfmailcomposeviewcontroller *picker = [[mfmailcomposeviewcontroller alloc] init]; picker.mailcomposedelegate = self; [picker setsubject: name]; // set recipients. nsarray *torecipients = [nsarray arraywithobjects:@"paul.haddell@bbmmjv.com",nil]; //nsarray *ccrecipients = [nsarray arraywithobjects:@"second@example.com",@"third@example.com", nil]; //nsarray *bccrecipients = [nsarray arraywithobjects:@"four@example.com",nil]; [picker settorecipients:torecipients]; //[picker setccrecipients:ccrecipients]; //[picker setbccrecipients:bccrecipients]; // attach image email. //nsstring *path = [[nsbundle mainbundle] pathforresource:@"ipodnano" oftype:@"png"]; //nsdata *mydata = [nsdata datawithcontentsoffile:path]; //[picker addattachmentdata:mydata mimetype:@"image/png" filename:@"ipodnano"]; // fill out email body text. //nsmutablestring *emailbody; testomail = [nsmutablestring stringwithformat: @"%@", testomail]; [picker setmessagebody:testomail ishtml:yes]; //html!!!!!! // nowadays mail service composition interface. [self presentviewcontroller:picker animated:yes completion:nil]; } } // mail service compose view controller delegate method - (void)mailcomposecontroller:(mfmailcomposeviewcontroller *)controller didfinishwithresult:(mfmailcomposeresult)result error:(nserror *)error { [self dismissmodalviewcontrolleranimated:yes]; } #pragma mark - mandare email /* - (void)sendmail:(nsmutablestring*)testomail{ mfmailcomposeviewcontroller *picker = [[mfmailcomposeviewcontroller alloc] init]; picker.mailcomposedelegate = self; [picker setsubject:@"reclutamento pompieri"]; // set recipients. nsarray *torecipients = [nsarray arraywithobjects:@"reda.bousbah@gmail.com",nil]; //nsarray *ccrecipients = [nsarray arraywithobjects:@"second@example.com",@"third@example.com", nil]; //nsarray *bccrecipients = [nsarray arraywithobjects:@"four@example.com",nil]; [picker settorecipients:torecipients]; //[picker setccrecipients:ccrecipients]; //[picker setbccrecipients:bccrecipients]; // attach image email. //nsstring *path = [[nsbundle mainbundle] pathforresource:@"ipodnano" oftype:@"png"]; //nsdata *mydata = [nsdata datawithcontentsoffile:path]; //[picker addattachmentdata:mydata mimetype:@"image/png" filename:@"ipodnano"]; // fill out email body text. nsstring *emailbody = @"it raining in sunny california!"; [picker setmessagebody:emailbody ishtml:no]; // nowadays mail service composition interface. [self presentviewcontroller:picker animated:yes completion:nil]; } */ #pragma mark - methods command keyboard - (ibaction)backgroundtap:(id)sender //method resign keyboard when background tapped { [nametextfield resignfirstresponder]; [emailtextfield resignfirstresponder]; [datetextfield resignfirstresponder]; [timetextfield resignfirstresponder]; [blanktextfield resignfirstresponder]; [blankbtextfield resignfirstresponder]; [mlabelcategory resignfirstresponder]; [messagetextview resignfirstresponder]; } - (ibaction)donebuttonpressed:(id)sender { nslog( @"done button pressed"); [sender resignfirstresponder]; } @end
ios uipickerview
Comments
Post a Comment