I'm looking for a little help with making phone call from my app. The phone number is formatted as (###) ###-####.
In my .h I have this:
IBOutlet UITextView *PhoneNumber;
In my .m I tried these:
- (IBAction)callPhone:(id)sender
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#",PhoneNumber.text]]];
I'm unable to make it dial out the number. But when I tried this its work.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:#########"]];
According to this site, the dashes should be ok. Just remove the parenthesis.
Related
I have a reader app that loads .epub files and usually I have no problem with selection at all, lately I have integrated fixed layout .epub files but I'm facing a problem: when I have a box containing one line the selection works fine, but when the box contains several lines, meaning several <p></p>, I cannot select a single word from the box. On selection the whole box gets selected as shown in the screenshot. When I try the same .epub file on iBooks, the selection works fine on all text. Any idea how I can fix the issue?
Here is the code for loading the file on UiWebView.
NSString *contents = [NSString stringWithContentsOfFile:itemPath encoding:NSUTF8StringEncoding error:nil];
if (!contents) {
contents = [NSString stringWithContentsOfFile:itemPath encoding:NSASCIIStringEncoding error:nil];
}
[readingWebView loadHTMLString:contents baseURL:baseURL];
I have finally got the answer.
When using this function:
NSString *jsString = [NSString stringWithFormat:#"document.getElementsByTagName('body')[0].webkitTextSizeAdjust= '%d%%'", font];
to set the font size some restrictions are set on the web view, one of them is related to the selection with fixed layout epubs.
I used instead:
NSString *jsString = [NSString stringWithFormat:#"document.getElementsByTagName('body')[0].style.fontSize= '%d%%'", font];
I have a viewcontroller with an iCarousel.
When I tap on an item that I know how to display an UIalert but, now I want to change view controller to go on an other already created viewcontroller
I'm guessing you need something like this:
MyOtherViewControllersName *vc =[[MyOtherViewControllersName alloc]initWithNibName:#"MyOtherViewControllersName" bundle:nil];
[self presentModalViewController:vc animated:YES];
Just put it in the same method where you're generating the alert message.
How to add UINavigationController to xCode Tab Bar Application Delegate?
My structure is based on xCode Tab Bar Application Delegate, with 2 tabs, First View & Second View respectively. For First View, I added a UITableView. I just want to make use of UINavigationController function [self.navigationController pushViewController:animated:] to push a subview and allow a navigation bar to be shown in subview. After pushing the subview, the tab bar must still be there.
Sounds simple, but I have no idea how to achieve it. Please help.
I started with a Window-based template instead and did this to achieve the same thing.
I created my NavigationControllers and TabBarController in my app delegate manually.
In your:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Add this:
//Seeting up the Navigation controllers and pushing our TableView controllers.
UINavigationController *unvc1 = [[UINavigationController alloc] init];
UINavigationController *unvc2 = [[UINavigationController alloc] init];
[unvc1 pushViewController:someViewController1 animated:NO];
[unvc2 pushViewController:someViewController2 animated:NO];
[someViewController1 release];[someViewController2 release];//Releasing our TableView controllers.
//Setting up the TabBar controller and pushing our Navigation controllers.
UITabBarController *tbvc = [[UITabBarController alloc] init];
tbvc.viewControllers = [NSArray arrayWithObjects:unvc1, unvc2, nil];
[unvc1 release];[unvc2 release]; //releasing our Navigation controllers.
I hope this helps.
I did this using presentModalViewController:animated . I added tabBar Controller in the modalView. In the method didSelectRowAtIndexPath use this presentModalViewController:animated .I might not be perfect but I had the same problem, but now my app works as I need.
I have a textview which contains chat history obtained from a server.The chat history is being constantly updated through a thread which I had started in a previous view. My problem is how do I constantly update my UITextView to reflect the changes?
self.textView.text = [[NSString alloc]initWithFormat:#"%#",chatHistory];
I use something like this:
NSString *newMessage = [NSString stringWithFormat:#"%#\n%#", [textView text], newChat];
[textView setText:newMessage];
also make sure your GUI updates are on the main application thread.
[self performSelectorOnMainThread:#selector(updateMyGui) withObject:nil waitUntilDone:NO];
I am trying to remove status bar from particular View Controller but still it shows blue line when i tried to Hide it so please give some suggestions for that.
[[UIApplication sharedApplication] setStatusBarHidden:YES];
In order to Hide the Status bar from Every View
try putting the code in your appdelegate file. in the applicationDidFinishLaunching method as follows
-(void)applicationDidFinishLaunching:(UIApplication *)application {
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
[window addSubview:tabBarController.view];
}