Rotate Address Book Controller - iphone

I am wondering if there is some way to rotate a created ABPeoplePickerNavigationController. I am creating the ABPeoplePickerNavigationController like this:
ABPeoplePickerNavigationController *addressBook = [[ABPeoplePickerNavigationController alloc] init];
addressBook.peoplePickerDelegate = self;
[self presentModalViewController:addressBook animated:YES];
My application is in landscape mode, and I am wondering how I can get this created controller to rotate like the rest of the application. As the Address Book application does this without any problems, I assume it is a pretty easy fix.
Thanks for any help!

I would look int possibly overriding - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation and making sure it returns YES for landscape.

Hope this may work , but try out atleast
[addressBook.view setTransform : CGAffineTransformMakeRotation( 90 * M_PI/ 180)];
The idea is to rotate the ABPeoplePickerNavigationController's view by transformation.

Related

SLComposeViewController Views sent to back in app and becomes unresponsive

I have a button in my app to bring up an SLComposeViewController for use with Twitter. When the view is presented it animates in correctly and the disappears. I have found that when it disappears it is sent to the back of the current view and I have no way to bring it back. I have tried manually sending all the views on top to the back in code with no luck. I feel there is something fundamentally wrong with my app for this to happen as this behaviour is seen at any level to the Navigation Controller in the app. Below is a screenshot of the SLComposeViewController being the Navigation Bar in the app, I made the ViewController's view have an Alpha value of 0.0f to illustrate my point:
I really don't know what is going on here and any help will be greatly appreciated. The code I am using to present the SLComposeViewController is pretty standard and I have tested it in another app and works fine:
NSString *message = [NSString stringWithFormat:#"#%#", [twitterInfo objectForKey:#"hashtag"]];
if ([appDelegate isSocialAvailable]) {
// code to tweet with SLComposeViewController
SLComposeViewController *twitter = [[SLComposeViewController alloc] init];
twitter = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[twitter setInitialText:[NSString stringWithFormat: #"%#", message]];
[self presentViewController:twitter animated:YES completion:nil];
}
Thanks for posting this, I had the same thing happen because I was adding a CAShapeLayer to my window for a gradient effect. Your post helped me figure out that this was the problem.
It looks like this is happening is because they are adding their view's layer to the window's sublayers--at index 0 I might add! This is contrary to what you would expect, which is that they would add their view as a subview to the presenting view controller's view.
They must have just thought that people don't add layers to their window and they want to make sure they are not competing with your view stack. Why they would put it into index 0 must only be because someone is in the habit of doing -[CALayer insertLayer:layer atIndex:0] I suppose.
I'm not certain but I am guessing this could be the case with any modal view controller.
The fix is pretty simple:
[viewController presentViewController:facebookViewController
animated:YES
completion:^{
facebookViewController.view.layer.zPosition = 1000;
}];
After a week of tearing my hair out to find a solution to this I have found the offending code in the app, a little trick to round the corners of the whole app, well make it seem like the corners are rounded by adding an image there:
UIImage *bottomOverlayImage = [UIImage imageNamed:#"bottom_overlay.png"];
CALayer *bottomOverlay = [CALayer layer];
bottomOverlay.frame = CGRectMake(0, self.window.frame.size.height - 9, bottomOverlayImage.size.width, bottomOverlayImage.size.height);
bottomOverlay.contents = (id)bottomOverlayImage.CGImage;
bottomOverlay.zPosition = 1;
[self.window.layer addSublayer:bottomOverlay];
If anybody could tell me why this code would mess up the Twitter View that would be really helpful for future reference. This code was placed in the app delegate and run on first load.

How to do horizontal slice between views?

I'm looking for some advice about the best way to create a multi-view iPhone application. This app will slice left to right and right to left when a it goes from one view to another. Very similar to how a navigation-based application but without the navigation top bar.
I'm doing some tests using this code:
- (IBAction)goToSettings:(id)sender {
SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:#"SettingsView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
something like UIModalTransitionStyleCoverHorizontal which doesn't exist.
So, I'm trying to do transitions, but now sure if that's the best way to do it, in terms of memory management, etc.
In summary, my application will have ~8 views, and I need to be able to navigate between them, going left to right into details, and go back to the left (previous view). What is the best way to do it?
Thanks in advance.
The navigation bar is optional in a navigation-based application. UINavigationController has a - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated method.
If for some reason that won't work, an alternative might be a paging UIScrollView, but that would be more hacky and more work to get what UINavigationController already gives you.

Problem when adding Three20 PhotoViewer to my UINavigationViewController

I want a photo viewer in my iphone app and I liked the Three20 photo viewer. I found it somehow hard to integrate it in my own app where I have my typical UINavigationViewController. So far I succeeded in doing the following:
TTURLMap *map = [[[TTURLMap alloc] init] autorelease];
[map from:#"tt://appPhotos" toSharedViewController:[PhotoViewController class]];
[self.navigationController pushViewController:[map objectForURL:#"tt://appPhotos"] animated:YES];
The only problem is that wenn I click back to my original view, its navigation bar keeps the style of the photo viewer (transperant and shows the view under it).
How can I get back my original navigation bar?
My experience: I once used three20's PhotoViewer and every time I went back from the PhotoViewer to my other view. The system status bar remained black and transparent (while it should be with default style). I solved it by manually and programmatically changing the status bar style every time when the back action was triggered.
Yes, this is a bit of an issue for sure. A good solution, as #diwup says, is to implement a manual fix. I tend to subclass TTPhotoViewer when I need it. Not only does it help with this problem but it also makes it much easier to use I find.
If you decide to subclass, then you should use whatever variation of the following you require:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.tintColor = myTintColor;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
However, if you don't want to subclass, you can always put the code into the - [viewWillAppear:] method of any class that comes after the photo viewer.

ABPersonViewController drawn under the navgation bar

The context:
I am working on an app that maintains a list of contacts along with their record IDs for it's own reference.
When the user needs to change the number associated with a specific contact within the app, I am trying to display the ABPersonViewController so the user can choose the new number from the contact in AB.
The problem:
The problem is that the ABPersonViewController that is opened is starting all the way from the top of the screen as if it does not know that there is a navigation bar on the top.
As a result some of the top part of the ABPersonViewController screen (the top part of the person image and the top part of the name) is underneath the navigation bar.
Ideally i want it to look like this, but not in edit mode: http://developer.apple.com/library/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Art/person_view.jpg
Also I wanted to add a "cancel" button to the top right part of the nav bar. Trying to add that as a bar button is not working either.
The code:
this is how I am adding the ABPersonViewController to the navigationController:
ABPersonViewController *personViewController = [[ABPersonViewController alloc] init];
personViewController.personViewDelegate = self;
personViewController.displayedPerson = person;
[self.m_circleNavController pushViewController:personViewController animated:YES];
[personViewController release];
The self here is a UIVIewController.
The m_circleNavController is the UINavigationController to which the UIVIewController belongs.
I tried these 2 ways of showing the person view, but both behave the same way.
[self.m_circleNavController pushViewController:personViewController animated:YES];
[self.navigationController pushViewController:personViewController animated:YES];
I'm not too sure what I am doing wrong, or what is the best way to do it.
I tried a lot of different ways to display it in vain.
The viewcontroller was behaving as though it was starting about 40 pixels above the top edge of the screen.
I was able to fix it in a very weird way finally. In the init function of the viewcontroller I added the following line:
self.view.bounds = CGRectMake(0, -43, 320, 440);
But still no clue as to why it happens this way. I was to close to the deadline to look for a decent solution.
Hello I've been having the same problem as of the new iOS. When this happens on my custom view controllers I have been able to correct it with:
if (self.interfaceOrientation != UIInterfaceOrientationPortrait) { // UI is in landscape position
[self.tableView setContentInset:UIEdgeInsetsMake(32,0,0,0)];
} else { // UI is in portrait position
[self.tableView setContentInset:UIEdgeInsetsMake(44,0,0,0)];
}
But when using the ABPersonViewController I don't quite know how to handle this problem.
Hope someone has an idea...

iOS4 ABNewPersonViewController Loses Data Entered when attempting to add a Photo iPhone 4

I have implemented a basic add contact feature to an iOS 4 application. Following the documentation from Apple, I have created a navigation controller, and set its root view to the ABNewPersonViewController. I have implemented the delegate as well. The basic mechanics all work.
The problem I am having is when you add a photo to the new person that is very large (taking a photo or picking one from the library), the ABNewPersonViewController form returns empty when the camera controls are dismissed. No photo is in the add photo box either. If I pick a small image (say a screenshot from the iPhone), everything works. I can see from the debug output: Received memory warning. Level=1
Has anyone else run into this? Is there a way to set the photo quality to a lower setting for the ABNewPersonViewController? Any help appreciated.
ABNewPersonViewController *abNewPersonView = [[ABNewPersonViewController alloc] init];
abNewPersonView.newPersonViewDelegate = self;
UINavigationController *newNavigationController = [UINavigationController alloc];
[newNavigationController initWithRootViewController:abNewPersonView];
[self presentModalViewController:newNavigationController animated:YES];
[abNewPersonView release];
[newNavigationController release];
If ABNewPersonViewController does not handle memory warnings correctly, file a bug with apple.