I am calling a phone using UIWebview which is giving me a alert with "Cancel" and "Call" I want to handle the "Call" and "Cancel" Btns, if i press "Call" i am able to call and if i dismiss the call it is coming back to my application, please help me in handling the "Call" and "Cancel" Btns
UIWebview *webview = [[UIWebView alloc] initWithFrame:[UIScreen Screen].applicationFrame];
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#",newNumber]]]];
Thanks a lot!
That is the default behavior of the application.
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[number stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
or
UIWebView *callWebview = [[UIWebView alloc] init];
NSURL *telURL = [NSURL URLWithString:];
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
see the difference.
Related
My app uses UIWebview, and it works well in iOS 5 and iOS 6. However, it doesn't load the webpage in iOS 7 when I build in Xcode 5 and run the same code.
- (void)webViewDidFinishLoad:(UIWebView *)webView {}
- (void)webViewDidStartLoad:(UIWebView *)webView {}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {}
All delegate function is not called. But I do set delegate in xib file and code
self.theWebView.delegate = self;
I didn't find any information via google. Thank you for your help.
I moved the loadRequest method to the completion handler of a presentViewController and it works in iOS 5, 6 and 7:
[self presentViewController:gwvc animated:YES completion:^(void){
[gwvc.wv loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.walkjogrun.net/about/eukanuba.html"]]];
}];
I found the root cause.
maybe I incorrectly used UIWebView, but it works in iOS5 and iOS6.
I don't know why it works in earlier iOS versions...
Moreover, it works in iOS7 when I build code with SDK 6.1.
Here's my old code.
RechargeWebPageViewController *webPageViewController;
webPageViewController = [[ RechargeWebPageViewController alloc] initWithNibName:#"WebPage" bundle:nil];
if (webPageViewController != nil) {
webPageViewController.hidesBottomBarWhenPushed = YES;
webPageViewController.delegate=self;
[self.navigationController pushViewController:webPageViewController animated:YES];
NSURL *url = [NSURL URLWithString:#"https://xxx.php"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
[webPageViewController loadRequest:request];
[request release];
}
I moved the loadRequest from the viewDidLoad method to the ViewWillAppear method, then it worked.
I think maybe UIWebView is not initialized correctly in my old code for iOS7.
I have a tableView, and a "Reload" button that fetches data from a URL and reloads the table, a costly operation (in particular the fetch part).
I want display info to the user while this is happening, so I thought I'd put up a "Loading" UITextView on top, do the fetch/reload operation, then remove the UITextView.
Here's the code:
- (IBAction)refreshData:(id)sender {
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height-30, self.view.frame.size.width, 30)];
[self.view addSubview:textView];
textView.text = #"Loading..";
textView.textColor = [UIColor whiteColor];
textView.backgroundColor = [UIColor grayColor];
textView.editable = NO;
[self fetchData];
[self.tableView reloadData];
[textView removeFromSuperview];
}
The behavior I get is that the fetchData executes before the UITextView renders on screen. I know this because I have NSLogs inside fetchData that execute before the UITextView shows up on screen.
Is there something obvious I'm missing here? Thanks.
Replace [self fetchData]; with
[self performSelectorInBackground:#selector(fetchData) withObject:nil];
Then inside your fetchData method, after your fetch is done, add
[self performSelectorOnMainThread:#selector(fetchDataFinished) withObject:nil waitUntilDone:NO];
where the new method fetchDataFinished is defined as
-(void) fetchDataFinished{
[self.tableView reloadData];
[self.textView removeFromSuperview];
}
Note that you have to make textView a property so it is accessible in this method.
I have not tried out the above for your particular case, but I have used similar constructs successfully in many similar situations.
I just wrote a iOS app to test the UIAlertView. When I ran it, the UIAlertView just appear with the screen went dark first without the UIAlertView, and "a long time" later ,the UIAlertView appeared. This happens on both Simulator and iPhone (IOS 4.2). I don't know why, Please help me, thanks.
Description:(You can also download the Project HERE)
Its a very simple View based app With 3 Classes: AppDelgate ViewControler and a TestOperation which implement NSOperation;
AppDelegate was just the one produced by XCode;
TestOperation.h:
#import <Foundation/Foundation.h>
#protocol TestOperationDelegate
- (void)didFinishTestOperaion;
#end
#interface TestOperation : NSOperation {
id <TestOperationDelegate> delegate;
}
#property (nonatomic, assign) id <TestOperationDelegate> delegate;
#end
TestOperation.m
#import "TestOperation.h"
#implementation TestOperation
#synthesize delegate;
- (void)main {
[delegate didFinishTestOperaion];
}
#end
ViewContoller.m
- (void)viewDidLoad {
[super viewDidLoad];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
TestOperation *testOperation = [[TestOperation alloc] init];
testOperation.delegate = self;
[queue addOperation:testOperation];
[testOperation release];
}
- (void)didFinishTestOperaion {
NSLog(#"start uialertview");
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Oops!" message:#"Here's the UIAlertView"
delegate:self cancelButtonTitle:#"Confirm" otherButtonTitles:nil];
[alert show];
[alert release];
}
//Solved!! Use performSelectorOnMainThread to make
the UI run on Main Thread
Solved!! Use performSelectorOnMainThread to make the UI run on Main Thread
[alert performSelectorOnMainThread:#selector(show) withObject:nil waitUntilDone:NO];
What are you attempting to test in the UIAlertView? If you simply called the UIAlertView from viewDidAppear: in your ViewController, is the UIAlertView displayed rapidly as expected?
I expect that the issues you are having are related to how you are calling the UIAlertView, and that the UIAlertView is being displayed before the UIView controlled by your ViewController has appeared.
I have a simple in app SMS view slide up when a button is pressed.
However in the Info.plist I have the status bar set to Opaque black style, but when the SMS view is shown the status bar changes to gray. And then changes back once the SMS view is dismissed.
this is the SMS code...
if([MFMessageComposeViewController canSendText])
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
NSString *MessageString = [NSString stringWithFormat:#"%# %#%#",Label2.text, Label4.text, Label1.text];
controller.body = MessageString;
controller.navigationBar.tintColor = [UIColor blackColor];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
Has else anyone run into this?
Is there a way to have the SMS view not change the status bar color?
Try this after you present the controller,
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
I have created navigation based project. and in second screen i want to add uitabbarcontroller. so can any one suggest how i do this.
i already did lot of search but no success yet. so please can you provide a simple sample of this. i already tried below discussion but i think its not a good approach.
Navigation Based Application with TabBar
Thanks
Actually this is the correct approach. The one thing that is not correct is where the controllers are allocated. This is happened in the previous controller, the one that is making the push, but should be allocated in the object that is responsible, the TabBarController.
When you implement your action to show the UITabBarController make the following code:
- (void) theAction {
SomeTabBarControllerSubClass *controller = [[SomeTabBarControllerSubClass alloc] init];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
Then when you implement the SomeTabBarControllerSubClass class:
(.h)
#interface SomeTabBarControllerSubClass : UITabBarController {
UIViewController *first;
UIViewController *second;
}
#end
(.m)
#implementation SomeTabBarControllerSubClass
- (void) viewDidLoad {
first = [[UIViewController alloc] init]; //Or initWithNib:
second = [[UIViewController alloc] init];
first.view.backgroundColor = [UIColor greenColor] //Just example
second.view.backgroundColor = [UIColor redColor] //Just example
first.tabBarItem.image = [UIImage imageNamed:#"someImage.png"];
self.viewControllers = [NSArray arrayWithObjects:first,second,nil];
}
- (void) dealloc {
[first dealloc];
[second dealloc];
[super dealloc];
}
#end