I'd like to display the camera view on only half the screen on both iPhone and iPad. I've done a lot of searching, but haven't found a solution.
try with this .. if this is not help full for you or facing any problem, tell me i will provide you some other sample code ..
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
UIView *controllerView = imagePickerController.view;
controllerView.alpha = 0.0;
controllerView.transform = CGAffineTransformMakeScale(0.5, 0.5);
[[[[UIApplication sharedApplication] delegate] window] addSubview:controllerView];
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
controllerView.alpha = 1.0;
}
completion:nil
];
[imagePickerController release];
Related
At first, sorry for my bad English, I'm just learning it. Im relatively new at Objective-C and I'm using FBConnect bundle to link my app to Facebook. All it's working correctly, but when I click a link into the UIWebView (the Facebook login button, for example), my UIWebView gets fullscreen and hides my close button (a little 'x' button in the top right of the UIWebView, called here "_closeButton").
Here's the code:
The "init" method:
- (id)init {
if ((self = [super initWithFrame:CGRectZero])) {
_delegate = nil;
_loadingURL = nil;
_showingKeyboard = NO;
self.backgroundColor = [UIColor clearColor];
self.autoresizesSubviews = NO;
//self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.contentMode = UIViewContentModeRedraw;
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(kPadding, kPadding, 480, 480)];
_webView.delegate = self;
//_webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:_webView];
//UIImage* closeImage = [UIImage imageNamed:#"FBDialog.bundle/images/close.png"];
UIImage* closeImage = [UIImage imageNamed:#"close"];
UIColor* color = [UIColor colorWithRed:255.0/255 green:/*184.0*/0.0/255 blue:/*216.0*/0.0/255 alpha:1];
_closeButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
[_closeButton setImage:closeImage forState:UIControlStateNormal];
[_closeButton setTitleColor:color forState:UIControlStateNormal];
[_closeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
[_closeButton addTarget:self action:#selector(cancel)
forControlEvents:UIControlEventTouchUpInside];
// To be compatible with OS 2.x
#if __IPHONE_OS_VERSION_MAX_ALLOWED <= __IPHONE_2_2
_closeButton.font = [UIFont boldSystemFontOfSize:12];
#else
_closeButton.titleLabel.font = [UIFont boldSystemFontOfSize:12];
#endif
_closeButton.showsTouchWhenHighlighted = YES;
_closeButton.autoresizingMask = UIViewAutoresizingFlexibleRightMargin
| UIViewAutoresizingFlexibleBottomMargin;
[self addSubview:_closeButton];
NSLog(#"close");
_spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleWhiteLarge];
_spinner.autoresizingMask =
UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin
| UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[self addSubview:_spinner];
_modalBackgroundView = [[UIView alloc] init];
}
return self;
}
The delegate of the WebView (I suspect here's where I need to do the trick)
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
NSURL* url = request.URL;
if ([url.scheme isEqualToString:#"fbconnect"]) {
if ([[url.resourceSpecifier substringToIndex:8] isEqualToString:#"//cancel"]) {
NSString * errorCode = [self getStringFromUrl:[url absoluteString] needle:#"error_code="];
NSString * errorStr = [self getStringFromUrl:[url absoluteString] needle:#"error_msg="];
if (errorCode) {
NSDictionary * errorData = [NSDictionary dictionaryWithObject:errorStr forKey:#"error_msg"];
NSError * error = [NSError errorWithDomain:#"facebookErrDomain"
code:[errorCode intValue]
userInfo:errorData];
[self dismissWithError:error animated:YES];
} else {
[self dialogDidCancel:url];
}
} else {
[self dialogDidSucceed:url];
}
return NO;
} else if ([_loadingURL isEqual:url]) {
return YES;
} else if (navigationType == UIWebViewNavigationTypeLinkClicked) {
if ([_delegate respondsToSelector:#selector(dialog:shouldOpenURLInExternalBrowser:)]) {
if (![_delegate dialog:self shouldOpenURLInExternalBrowser:url]) {
return NO;
}
}
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
} else {
return YES;
}
}
And the show method (called when I need to show the Web View)
- (void)show {
NSLog(#"Cuantas veces me ves?");
[self load];
[self sizeToFitOrientation:NO];
CGFloat innerWidth = self.frame.size.width - (kBorderWidth+1)*2;
[_closeButton sizeToFit];
_closeButton.frame = CGRectMake(
2,
2,
29,
29);
_webView.frame = CGRectMake(
kBorderWidth+1,
kBorderWidth+1,
innerWidth,
self.frame.size.height - (1 + kBorderWidth*2));
[_spinner sizeToFit];
[_spinner startAnimating];
_spinner.center = _webView.center;
UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) {
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
_modalBackgroundView.frame = window.frame;
[_modalBackgroundView addSubview:self];
[window addSubview:_modalBackgroundView];
[window addSubview:self];
[self dialogWillAppear];
self.transform = CGAffineTransformScale([self transformForOrientation], 0.001, 0.001);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kTransitionDuration/1.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(bounce1AnimationStopped)];
self.transform = CGAffineTransformScale([self transformForOrientation], 1.1, 1.1);
[UIView commitAnimations];
[self addObservers];
}
Googling the problem, I found that this could be the Default behaviour of the UIWebView. How can I change it to make all my WebViews of the same size than the first one?
Thanks in advance!
== EDIT ==
Still don't know why is my UIWebView acting like this, or how to solve it, but since the code is part of the FBConnect Bundle, I suppose I shouldn't edit it too much. I just created programmatically a new close button on the top and that's all. But I'll let the question open if someone knows how to solve it. Thanks to Leo Natan for his help.
I am developing one application.In that I am using the UIImagePickerController.That one will be opened total screen.But i need to open that picker at the middle of the screen(50,50,220,380).So please tell mw how can i do this one.
I ended up with a lovely miniature camera imagePicker floating in the middle of my screen using the following
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
// imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
// imagePickerController.cameraCaptureMode = UIImagePickerControllerSourceTypePhotoLibrary;
UIView *controllerView = imagePickerController.view;
controllerView.alpha = 0.0;
controllerView.transform = CGAffineTransformMakeScale(0.5, 0.5);
[[[[UIApplication sharedApplication] delegate] window] addSubview:controllerView];
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
controllerView.alpha = 1.0;
}
completion:nil
];
How do I add UISplitView after clicking on the SingleView application? Clearly when the user has successfully logged in then they will see splitView? How is it possible? Please give me guidelines or if possible then code for that because I'm new to iPhone development and I haven't more knowledge for it?
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 1.90];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:#"MasterViewController" bundle:nil];
if (!masternavigationController) {
masternavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
}
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:#"DetailView" bundle:nil];
if (!splitViewController) {
splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:masternavigationController, detailViewController, nil];
UIViewController *view_controller = (UIViewController *)[navigationController.viewControllers objectAtIndex:([navigationController.viewControllers count]-1)];
[masternavigationController.navigationBar setHidden:TRUE];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[splitViewController.view setBounds:CGRectMake(0, 0, 1024, 748)];
[splitViewController.view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
[view_controller.view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
view_controller.view.tag = 17;
[UIView animateWithDuration:1.05 animations:^{navigationController.view.alpha = 0.0;} completion:^(BOOL finished){
[navigationController.view addSubview:splitViewController.view];
[UIView animateWithDuration:1.00 animations:^{navigationController.view.alpha = 1.0;} completion:nil];}];
rootview *rtview = [[rootview alloc] initWithNibName:#"rootview" bundle:nil];
rtview.delegate = detailViewController;
[detailViewController.view addSubview:rtview.view];
flag = YES;
[rtview release];
}
[UIView commitAnimations];
// [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:#selector(doneAnimation) userInfo:nil repeats:NO];
[masterViewController release];
[detailViewController release];
This is how we have to add splitview controler you have to check the condition weather you are logged in or not and then call this in a method
Is it possible to open webview during use of camera in app.if it is possible plz let me know.
You could try:
- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject
{
//NSLog(#"008 ::Create Postcard :: start photo camera");
if ((![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) || (delegateObject == nil) || (controller == nil)) {
return NO;
}
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
UIView *overlay = [[UIView alloc]initWithFrame:CGRectMake(x, y, w, h)];
// overlay.transform = CGAffineTransformMakeRotation(M_PI / 2.0);
// overlay.backgroundColor = [UIColor redColor];
{create your webview here}
[overlay addSubview:webview];
[webview release];
[picker.cameraOverlayView = overlay;
[controller presentModalViewController:picker animated:YES];
return YES;
}
If you have enough recources on the phone it might could work i guess
Apple provides the code to use MFMailComposeViewController.but it uses
- (IBAction)buttonPressed
{
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc]init];
controller.mailComposeDelegate = self;
[controller setSubject:#"In app email..."];
[controller setMessageBody:#"...a tutorial from mobileorchard.com" isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];
}
by default it uses bottom UP transition.suppose if i want to use following, it gives wrong
ouput.can i use other add subview like that instead of presentModalViewController
{
UIViewAnimationTransition trans = UIViewAnimationTransitionFlipFromRight;
[UIView beginAnimations: nil context: nil];
[UIView setAnimationTransition:trans forView: [self view] cache: YES];
[self presentModalViewController: controller animated:YES];
[UIView commitAnimations];
}
it works correctly for other view controller,but it did not work in MFMailComposeViewController any help please?
hi i have done like this,but current view controller flips, and then composer comes from
bottom..?will you help?
- (IBAction)clickedMailButton:(id)sender
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mcontroller = [[MFMailComposeViewController alloc]init];
//[mcontroller setSubject:#"My Pocket Schedule"];
[mcontroller setTitle:#"New Message"];
[mcontroller setMessageBody:#"Check out My Pocket Schedule in the iTune Store" isHTML:NO];
mcontroller.mailComposeDelegate = self;
UIViewAnimationTransition trans = UIViewAnimationTransitionFlipFromRight;
[UIView beginAnimations: nil context: nil];
[UIView setAnimationTransition:trans forView: [self view] cache: YES];
[self presentModalViewController:mcontroller animated:YES];
[UIView commitAnimations];
[mcontroller release];
}
Use the modalTransitionStyle property:
MFMailComposeViewController *mcontroller = [[MFMailComposeViewController alloc] init];
[mcontroller setTitle:#"..."];
[mcontroller setMessageBody:#"..." isHTML:NO];
mcontroller.mailComposeDelegate = self;
mcontroller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:mcontroller animated:YES];
[mcontroller release];
Try
presentModalViewController:withTransition: