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

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.

Related

FBFriendPickerViewController for iOS 7 doesn't work as expected in landscape mode

I am working for Facebook integration in my iPad app. I am using FBFriendPickerViewController for same. My app is working fine on iOS 6 for landscape as well as portrait mode but when I use iOS 7 then friend picker controller works fine ONLY for portrait. When try to launch it in landscape mode then white view pops up. I could see faint friend picker view in background but very hard to see that. Do anyone have any idea what must be the reason? Code base I have used is as below.
if (!_friendPicker) {
self.friendPicker = [[FBFriendPickerViewController alloc] init];
// _friendPicker.delegate = self;
_friendPicker.title = #"Select a friend";
_friendPicker.allowsMultipleSelection = NO; // Share dialog doesn't allow more than one recipient
}
[_friendPicker clearSelection];
[_friendPicker loadData];
_friendPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[_friendPicker presentModallyFromViewController:self
animated:YES
handler:nil];
Same thing I have observed on facebook sample app "HelloFacebookSample" :)
Try:
Get the newest Facebook SDK, because in the above link a Facebook rep says the issue should be resolved. The modal frame still takes into account the space for the status bar so you'll have to find a way to deal with it (doesn't bother me enough to spend time solving it at this point).
I also removed a [[UINavigationBar appearance] setTitleTextAttributes:]; line from my app delegate, so maybe try removing all nav bar customisation and see what you get.
Good luck.

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.

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.

How to convert an iPhone app to an iPad app

I am a beginner, and I have an iPhone app.
I want to convert iPhone app to iPad app.
I want to increase the size of all control, images and views according to iPad dimensions programmatically as I have no controls in XIB but in fact they are programmatically made.
I don't want to change the dimensions manually at every place because it is too much of a cumbersome work.
Is there any way I can do this in a better way?
The simple answer is NO.
You have to do it manually. There is no automatic system.
That is the correct answer.
if you have an absolutely trivial app - ie, with no images or controls or layouts! - you can of course just change it to an iPad app.
The questioner is asking specifically how to change all the images, layouts, and so on in a normal app. The answer is it must all be done completely manually. There is no automatic system for re-doing design or re-doing images in Photoshop, etc.
Note that similarly if you want to do both portrait and landscape layouts of an app, you or your designers have to of course simply design both layouts. There's no, say, "artificial intelligence" system that automatically does art direction for the app! You simply have to manually design both layouts and manually build in Photoshop all necessary images for each situation. The same applies to iPad v. iPhone.
(Note that sometimes you will have to do four totally different layouts, and sets of graphics .. for the phone/pad and portrait/landscape.)
This is exactly why iPad apps are sometimes labelled "HD" in the app store - they are of course totally different.
In Xcode, click on your project on the "Groups & Files" sidebar. Press command-I. Search for Targeted Device Family and change it from iPhone to iPad. Then it will compile and run on an iPad but the UI might look a bit funky.
What I did after that was open the xib I used for my iPhone app's FlipSide view (the one that looks funky on the iPad) go to File->Create iPad version and save it as FlipSideiPad.
Then when I load the view controller, I used the following if statement to tell my program to load the iPhone interface if the device is an iPhone or to load the iPad interface if the device is an not an iPhone.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:#"FlipsideView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
else
{
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:#"iPadFlipsideView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
I hope that helps.
You need to resize the view manually...there is no such single methods for converting iphone app to ipad

How to add refresh button to iPhone RSS Reader app?

I'm playing around with this application I got on last months Web Designer that's a very basic RSS reader. I would like to add a refresh button to the top navigation bar that refreshes all the content in the table but can't seem to work out how to do it. I've worked out it must somehow use the [tablename Reload] function, but have got no idea how to implement it.
I'm new to all this so simple instructions are good instructions :) I know how to add the button, its linking it to and defining the actions when the user clicks it that I'm struggling with.
You can grab the code here http://www.webdesignermag.co.uk/tutorial-files/issue-162-tutorial-files/ under iPhone Apps (it's the only one).
This is what you need to do in the RootViewController.m:
In the viewDidLoad function, add a button of type UIBarButtonSystemItemRefresh, associate to it an Action and a Target, (infact, as Alan told you, you need to learn about Outlets and Actions)
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:#selector(refreshTable)];
self.navigationItem.rightBarButtonItem = refreshButton;
Implement refreshTable function (if not declared in .h, have to put it above viewDidLoad())
- (void)refreshTable{
[rssParser release];
rssParser = [[RSSXMLParser alloc] init];
[rssParser parseRSSFeed];
[self.tableView reloadData];
NSLog(#"table is refreshing ....");
}
Hi Graeme and velcome to SO.
For the iphone UI, you have to define outlets and actions, and use Interface Builder to link them together.
This page has some information that should hopefully get you started.
Understanding Outlets and Actions