On iOS 6 when a player is not signed in and is trying to use GameCenter an UIAlertView with the text that i put in title pops up. "game center unavailable player is not signed in". My question is is it possible to replace that UIAlertView with anything else, with my own interface element?
[GKLocalPlayer localPlayer].authenticateHandler = ^(UIViewController *viewController, NSError *error)
{
if ([[GKLocalPlayer localPlayer] isAuthenticated])
{
NSLog(#"[gamecenter] player authenticated: %#\n", [GKLocalPlayer localPlayer]);
[self gamecenterLoadAchievements];
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite)
{
// Insert application-specific code here to clean up any games in progress.
if (acceptedInvite)
{
NSLog(#"Accepted invitation");
isInvited = YES;
[[GameLevel sharedGameLevel] setCurrentGameMode:GameModeGameCenter];
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease];
mmvc.matchmakerDelegate = self;
AppDelegate * delegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
[delegate.viewController presentModalViewController:mmvc animated:YES];
}
else if (playersToInvite)
{
NSLog(#"Players to invite");
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = 2;
request.maxPlayers = 2;
request.playersToInvite = playersToInvite;
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = self;
[presentingViewController presentModalViewController:mmvc animated:YES];
}
};
}
else
if (viewController)
{
AppDelegate *delegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
NavigationController *_viewController = delegate.viewController.navController;
[_viewController presentViewController: viewController animated: YES completion:nil];
}
else
{
NSLog(#"[gamecenter] %#\n", error);
gcLoginFailed = YES;
if ([[error domain] isEqualToString:GKErrorDomain])
{
if ([error code] == GKErrorNotSupported)
gcIsSupported = NO;
else
if ([error code] == GKErrorCancelled)
gcLoginCancelled = YES;
}
}
};
Just not use UIAlertView Use your own graphics with a UIButton
If you are using the disableGameCenter method in authenticating , just don't use it , instead of it use a integer ilk int isPlayerSignedIn . And just return it to 1 or 0 . So ;
if (isPlayerSignedIn==0) {
//display your graphics
}
else do nothing .
edit :
else
if (viewController)
{
AppDelegate *delegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
NavigationController *_viewController = delegate.viewController.navController;
[_viewController presentViewController: viewController animated: YES completion:nil];
}
just if you don't use these lines of code you will see that you don't get that UIAlertView
Then you can implement a "game center is unavailable" staff , but additionally you have to implement a login screen too.
Related
I have problem with ABPeoplePickerNavigationController in IOS 7 with the following error
*** -[ABPeoplePickerNavigationController respondsToSelector:]: message sent to deallocated instance 0x9b4b050
on IOS 6 it is working fine but in ios 7 it gives this error with zombies enabled without zombies it was like
Thread 1: EXC_BAD_ACCESS(code=2,address=0x0)
than i enable zombies
here is my code
- (void)viewDidLoad
{
[super viewDidLoad];
self.contacts = [[NSMutableArray alloc] initWithCapacity:10];
self.addressBook=ABAddressBookCreateWithOptions(NULL, NULL);
[self checkAddressBookAccess];
}
(void)requestAddressBookAccess
{
ContactsViewController * __weak weakSelf = self;
ABAddressBookRequestAccessWithCompletion(self.addressBook, ^(bool granted, CFErrorRef error)
{
if (granted)
{
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf accessGrantedForAddressBook];
});
}
});
}
-(void)accessGrantedForAddressBook
{
NSMutableArray *savedContacts=[[NSMutableArray alloc] initWithArray:[DatabaseHandler getAllContacts]];
if (savedContacts &&savedContacts.count!=0)
[self.contacts addObjectsFromArray:savedContacts];
}
- (IBAction)popUpAddExistingContact:(id)sender {
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[picker setDelegate:self];
[self presentViewController:picker animated:YES completion:nil];
}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
NSString *viewControllerDesc=[viewController description];
NSString *t_st = #"ABContactViewController";
NSRange rang =[viewControllerDesc rangeOfString:t_st options:NSCaseInsensitiveSearch];
if (rang.length == [t_st length])
{
navigationController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(addPerson:)];
}
else if([navigationController isKindOfClass:[ABPeoplePickerNavigationController class]] && [viewController isKindOfClass:[ABPersonViewController class]])
{
ABPersonViewController *DVC=(ABPersonViewController*)viewController;
self.currentPerson=DVC.displayedPerson;
navigationController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(addPerson:)];
}
else{
navigationController.topViewController.navigationItem.rightBarButtonItem = nil;
}
navigationController.topViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:#selector(cancel:)];
}
-(IBAction)addPerson:(id)sender{
if (self.currentPerson!=NULL)
{
CFStringRef firstName;
int recordID;
firstName = ABRecordCopyValue(self.currentPerson, kABPersonFirstNameProperty);
recordID = ABRecordGetRecordID(self.currentPerson);
MyContact *contact=[[MyContact alloc] init];
contact.Name=(__bridge NSString *)(firstName);
contact.contactID=[NSString stringWithFormat:#"%i",recordID];
contact.phones=[[NSMutableArray alloc] init];
ABMultiValueRef phones = ABRecordCopyValue(self.currentPerson, kABPersonPhoneProperty);
for(CFIndex j = 0; j < ABMultiValueGetCount(phones); j++)
{
CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(phones, j);
CFStringRef locLabel = ABMultiValueCopyLabelAtIndex(phones, j);
NSString *phoneNumber = (__bridge NSString *)phoneNumberRef;
[contact.phones addObject:phoneNumber];
CFRelease(phoneNumberRef);
CFRelease(locLabel);
}
CFRelease(firstName);
//CFRelease(lastName);
}
//[self dismissModalViewControllerAnimated:YES];
[self dismissViewControllerAnimated:YES completion:^(void ){
[self.popUpContactView removeFromSuperview];
}];
}
as soon as peoplepickercontroller is dismissed app crashed in ios 7
*** -[ABPeoplePickerNavigationController respondsToSelector:]: message sent to deallocated instance 0xb236c00
0x17d811: jmp 0x17d90c ; ___forwarding___ + 1020
Thread 1:EXC_BREAKPOINT (code=EXC_1386_BPT,sucode 0x0)
try to set peopleViewController delegates to nil before dismissing and disable second possible call of this action during some time (like if user pressed button several times). Assume you have a reference to ABPeoplePickerNavigationController instance. Something name like self.adressBook;
Then before dismissing PeoplePickerNavigationController set
self.adressBook.peoplePickerDelegate = nil
self.adressBook.delegate = nil;
and make sure that you do not call your peoplePickerNavigationController reference after dismissing or your reference to this instance is of weak, not assign type.
- (IBAction)popUpAddExistingContact:(id)sender {
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[picker setDelegate:self];
[self presentViewController:picker animated:YES completion:nil];
}
I think it is because the view controller created is not retained,
Call [self addChildViewController:picker] or else maintain a "strong" reference for it
I am working on ELCAlbumPickerController, i am able to select multiple images and upload, but in addition i want to get the file name and datatype of the file. how can i do that?
I am able to select either image or video , how can i select both image and video and any file at a time?
Please find my code below for your reference.
- (void)viewDidLoad {
UIImage *anImage = [UIImage imageNamed:#"elc-ios-icon.png"];
NSArray *Items = [NSArray arrayWithObjects:
#"A text line",
anImage, nil];
UIActivityViewController *ActivityView =
[[UIActivityViewController alloc]
initWithActivityItems:Items applicationActivities:nil];
[self presentViewController:ActivityView animated:YES completion:nil];
}
- (IBAction)launchController
{
ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] initWithNibName: nil bundle: nil];
ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
[albumController setParent:elcPicker];
[elcPicker setDelegate:self];
ELCImagePickerDemoAppDelegate *app = (ELCImagePickerDemoAppDelegate *)[[UIApplication sharedApplication] delegate];
if ([app.viewController respondsToSelector:#selector(presentViewController:animated:completion:)]){
[app.viewController presentViewController:elcPicker animated:YES completion:nil];
} else {
[app.viewController presentModalViewController:elcPicker animated:YES];
}
[elcPicker release];
[albumController release];
}
- (IBAction)launchSpecialController
{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
self.specialLibrary = library;
[library release];
NSMutableArray *groups = [NSMutableArray array];
[_specialLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[groups addObject:group];
} else {
// this is the end
[self displayPickerForGroup:[groups objectAtIndex:0]];
}
} failureBlock:^(NSError *error) {
self.chosenImages = nil;
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"Error" message:[NSString stringWithFormat:#"Album Error: %# - %#", [error localizedDescription], [error localizedRecoverySuggestion]] delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
NSLog(#"A problem occured %#", [error description]);
// an error here means that the asset groups were inaccessable.`
// Maybe the user or system preferences refused access.
}];
}
- (void)displayPickerForGroup:(ALAssetsGroup *)group
{
ELCAssetTablePicker *tablePicker = [[ELCAssetTablePicker alloc] initWithNibName: nil bundle: nil];
tablePicker.singleSelection = YES;
tablePicker.immediateReturn = YES;
ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:tablePicker];
elcPicker.delegate = self;
tablePicker.parent = elcPicker;
// Move me
tablePicker.assetGroup = group;
[tablePicker.assetGroup setAssetsFilter:[ALAssetsFilter allAssets]];
if ([self respondsToSelector:#selector(presentViewController:animated:completion:)]){
[self presentViewController:elcPicker animated:YES completion:nil];
} else {
[self presentModalViewController:elcPicker animated:YES];
}
[tablePicker release];
[elcPicker release];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
}
#pragma mark ELCImagePickerControllerDelegate Methods
- (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info
{
if ([self respondsToSelector:#selector(dismissViewControllerAnimated:completion:)]){
[self dismissViewControllerAnimated:YES completion:nil];
} else {
[self dismissModalViewControllerAnimated:YES];
}
for (UIView *v in [_scrollView subviews]) {
[v removeFromSuperview];
}
CGRect workingFrame = _scrollView.frame;
workingFrame.origin.x = 0;
images = [NSMutableArray arrayWithCapacity:[info count]];
for(NSDictionary *dict in info) {
UIImage *image = [dict objectForKey:UIImagePickerControllerOriginalImage];
[images addObject:image];
UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
imageview.frame = workingFrame;
[_scrollView addSubview:imageview];
[imageview release];
workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
}
self.chosenImages = images;
NSLog(#"Images:%#",images);
[_scrollView setPagingEnabled:YES];
[_scrollView setContentSize:CGSizeMake(workingFrame.origin.x, workingFrame.size.height)];
for (int i=0; i< images.count; i++) {
NSData *image = UIImageJPEGRepresentation(images[i], 0.1);
NSLog(#"NSDATA:%#",image);
NSMutableString *urlString = [[NSMutableString alloc] initWithFormat:#"name=thefile&&filename=recording"];
[urlString appendFormat:#"%#", image];
NSLog(#"urlstring:%#",urlString);
NSData *postData = [urlString dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSString * namecount=[NSString stringWithFormat:#"fn%i.png",i];
NSString * baseurl =[[NSString alloc]initWithFormat:#"http://199.198.12.555/serviceService.svc/serviceupload?fileName=%#",namecount];
NSURL *url = [NSURL URLWithString:baseurl];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setHTTPMethod: #"POST"];
[urlRequest setValue:postLength forHTTPHeaderField:#"Content-Length"];
[urlRequest setValue:#"application/x-www-form-urlencoded"
forHTTPHeaderField:#"Content-Type"];
[urlRequest setHTTPBody:image];
NSURLConnection *connection = [NSURLConnection connectionWithRequest:urlRequest delegate:self];
[connection start];
}
NSLog(#"%#",images[0]);
NSLog(#"%lu",(unsigned long)images.count);
}
-(IBAction)upload:(id)sender{
}
- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
{
if ([self respondsToSelector:#selector(dismissViewControllerAnimated:completion:)]){
[self dismissViewControllerAnimated:YES completion:nil];
} else {
[self dismissModalViewControllerAnimated:YES];
}
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload
{
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc
{
[_specialLibrary release];
[_scrollView release];
[super dealloc];
}
#end
#implementation APActivityProvider
- (id) activityViewController:(UIActivityViewController *)activityViewController
itemForActivityType:(NSString *)activityType
{
if ( [activityType isEqualToString:UIActivityTypePostToTwitter] )
return #"This is a #twitter post!";
if ( [activityType isEqualToString:UIActivityTypePostToFacebook] )
return #"This is a facebook post!";
if ( [activityType isEqualToString:UIActivityTypeMessage] )
return #"SMS message text";
if ( [activityType isEqualToString:UIActivityTypeMail] )
return #"Email text here!";
if ( [activityType isEqualToString:#"it.albertopasca.myApp"] )
return #"OpenMyapp custom text";
return nil;
}
- (id) activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController { return #""; }
#end
#implementation APActivityIcon
- (NSString *)activityType { return #"it.albertopasca.myApp"; }
- (NSString *)activityTitle { return #"Open Maps"; }
- (UIImage *) activityImage { return [UIImage imageNamed:#"elc-ios-icon.png"]; }
- (BOOL) canPerformWithActivityItems:(NSArray *)activityItems { return YES; }
- (void) prepareWithActivityItems:(NSArray *)activityItems { }
- (UIViewController *) activityViewController { return nil; }
- (void) performActivity {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"maps://"]];
}
#end
Thanks
You can get the asset URL using the key UIImagePickerControllerReferenceURL which would give the 'name', but that probably won't be very useful as its probably a UUID. The UIImagePickerControllerMediaType key contains the type.
I'm working on a game center multiplayer app and I've found something that makes me scratch my head. I can receive game invites just fine as long as both devices do not have the GKMatchmakerViewController up and running. However, when both devices have it open and an invitation is sent out, nothing happens after the user selects "Accept" on the alert banner. Are there any good working examples out there that show how to do this? I'm working with Ray Wenderlich's GCHelper and have not made any progress with this issue for weeks.
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite)
{
NSLog(#"Received invite!!!");
self.pendingInvite = acceptedInvite;
self.pendingPlayersToInvite = playersToInvite;
Class gcClass = (NSClassFromString(#"GKLocalPlayer"));
NSString *reqSysVer = #"5.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer
options:NSNumericSearch] != NSOrderedAscending);
gameCenterAvailable=gcClass && osVersionSupported;
if (!gameCenterAvailable) return;
matchStarted = NO;
self.match = nil;
if (acceptedInvite) {
NSLog(#"pendingInvite != nil");
AppDelegate *gcdelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
[gcdelegate.viewController dismissModalViewControllerAnimated:YES];
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:pendingInvite];
mmvc.matchmakerDelegate = self;
[gcdelegate.viewController presentModalViewController:mmvc animated:YES];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
boo_invite=true;
}
else {
NSLog(#"pendingInvite == nil");
AppDelegate *gcdelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
[gcdelegate.viewController dismissModalViewControllerAnimated:NO];
request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 4;
request.playersToInvite = pendingPlayersToInvite;
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
mmvc.matchmakerDelegate = self;
[gcdelegate.viewController dismissModalViewControllerAnimated:YES];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
}
};
I think the issue is has to do with"
Warning: Attempt to present
on while a presentation is in
progress!
What do I need to do to fix this?
Looks like the problem was that it wasn't waiting long enough for the controller to be dismissed.
[gcdelegate.viewController dismissViewControllerAnimated:YES
completion:^{
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithInvite:pendingInvite];
mmvc.matchmakerDelegate = self;
[gcdelegate.viewController presentModalViewController:mmvc animated:YES];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
boo_invite=true;
}];
Took care of it.
i display route from start to end point in mapView in iphone and i done it.But after one day i open this project and it does not display route because UICGDirectionsDelegate functions are not called. I dont know why its happen kindly some body guide me about this problem.Many thanks and my sample code is here`
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
if (diretions.isInitialized) {
[self update];
}
routeOverlayView = [[UICRouteOverlayMapView alloc] initWithMapView:mapViews];
diretions = [UICGDirections sharedDirections];
diretions.delegate = self;
}
- (IBAction)backButton:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)update {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
UICGDirectionsOptions *options = [[UICGDirectionsOptions alloc] init];
options.travelMode = travelMode;
if (is_route) {
startPoint = [NSString stringWithFormat:#"%f,%f",APPDELEGATE.user_latitude,APPDELEGATE.user_longitude];
endPoint = [NSString stringWithFormat:#"%#,%#",routeObj.latitude,routeObj.longitude];
destination = poiObj.english_title;
}else {
startPoint = [NSString stringWithFormat:#"%f,%f",APPDELEGATE.user_latitude,APPDELEGATE.user_longitude];
endPoint = [NSString stringWithFormat:#"%# ,%#",poiObj.latitude,poiObj.longitude];
destination = routeObj.starting_poi_name;
}
[diretions loadWithStartPoint:startPoint endPoint:endPoint options:options];
}
- (void)moveToCurrentLocation:(id)sender {
[mapViews setCenterCoordinate:[mapViews.userLocation coordinate] animated:YES];
}
- (void)addPinAnnotation:(id)sender {
UICRouteAnnotation *pinAnnotation = [[UICRouteAnnotation alloc] initWithCoordinate:[mapViews centerCoordinate]
title:nil
annotationType:UICRouteAnnotationTypeWayPoint];
[mapViews addAnnotation:pinAnnotation];
}
#pragma mark <UICGDirectionsDelegate> Methods
- (void)directionsDidFinishInitialize:(UICGDirections *)directions {
[self update];
}
- (void)directions:(UICGDirections *)directions didFailInitializeWithError:(NSError *)error {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Map Directions" message:[error localizedFailureReason] delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
}
- (void)directionsDidUpdateDirections:(UICGDirections *)directions {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
// Overlay polylines
UICGPolyline *polyline = [directions polyline];
NSArray *routePoints = [polyline routePoints];
[routeOverlayView setRoutes:routePoints];
// Add annotations
currentLocation = #"You are here";
UICRouteAnnotation *startAnnotation = [[UICRouteAnnotation alloc] initWithCoordinate:[[routePoints objectAtIndex:0] coordinate]
title:currentLocation
annotationType:UICRouteAnnotationTypeStart];
UICRouteAnnotation *endAnnotation = [[UICRouteAnnotation alloc] initWithCoordinate:[[routePoints lastObject] coordinate]
title:destination
annotationType:UICRouteAnnotationTypeEnd];
[mapViews addAnnotations:[NSArray arrayWithObjects:startAnnotation, endAnnotation, nil]];
}
- (void)directions:(UICGDirections *)directions didFailWithMessage:(NSString *)message {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Map Directions" message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[alertView show];
}
`
In UICGRoute.m
Replace this
NSArray *stepDics;
NSDictionary *k;
for (int i = 0; i<allKeys.count; i++) {
k = [dictionaryRepresentation objectForKey:[allKeys objectAtIndex:i]];
if ([k objectForKey:#"Steps"]) {
stepDics = [k objectForKey:#"Steps"];
break;
}
}
with
NSDictionary *k = [dictionaryRepresentation objectForKey:[allKeys objectAtIndex:[allKeys count] - 1]];
NSArray *stepDics = [k objectForKey:#"Steps"];
I am sending sms programmatically from my view controller but now it is showing me statusbar and vertical black line
my code:
- (IBAction)SendTextBtnTapped:(id)sender {
[self sendSMS:#"Body of SMS..." recipientList:[NSArray arrayWithObjects: nil]];
}
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:YES];
if (result == MessageComposeResultCancelled)
NSLog(#"Message cancelled");
else if (result == MessageComposeResultSent)
NSLog(#"Message sent");
else
NSLog(#"Message failed");
}
just add this line
controller.wantsFullScreenLayout = YES;
OR add this line after present MessageViewController like bellow..
[self presentModalViewController:controller animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
OR for whole this viewController use bellow loginin viewWillAppear: paste this code..
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
I think you can use wantsFullScreenLayout.
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
controller.wantsFullScreenLayout = YES; //<== add this
[self presentModalViewController:controller animated:YES];
}